This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
Bogus code in segfault lib
- To: libc-hacker@cygnus.com
- Subject: Bogus code in segfault lib
- From: Mark Kettenis <kettenis@phys.uva.nl>
- Date: Sat, 12 Sep 1998 19:49:03 +0200 (CEST)
Hi,
IMHO the logic for using an alternative signal stack in the current
version is wrong. `SS_ONSTACK' is supposed to set by the OS,
signalling that the process is currenty executing on the alternative
stack. To tell the OS to actually use the stack you have to install
the handler with the `SA_ONSTACK' bit set (and of course register the
stack with `sigaltstack').
Mark
1998-09-12 Mark Kettenis <kettenis@phys.uva.nl>
* sysdeps/generic/segfault.c (install_handler): Install signal
handler with SA_ONSTACK instead of setting the stack flags to
SS_ONSTACK. Do not install handler for SIGSTKFLT if it is not
defined.
Index: sysdeps/generic/segfault.c
--- 0.11/sysdeps/generic/segfault.c Sat, 29 Aug 1998 20:19:05 +0200 kettenis (libc/6_segfault.c 1.1.1.1.1.1 666)
+++ Local.13(w)/sysdeps/generic/segfault.c Sat, 29 Aug 1998 20:30:06 +0200 kettenis (libc/6_segfault.c 1.1.1.1.1.2 644)
@@ -163,6 +163,23 @@
sigemptyset (&sa.sa_mask);
sa.sa_flags = SA_RESTART;
+ /* Maybe we are expected to use an alternative stack. */
+ if (getenv ("SEGFAULT_USE_ALTSTACK") != 0)
+ {
+ void *stack_mem = malloc (2 * SIGSTKSZ);
+ struct sigaltstack ss;
+
+ if (stack_mem != NULL)
+ {
+ ss.ss_sp = stack_mem;
+ ss.ss_flags = 0;
+ ss.ss_size = 2 * SIGSTKSZ;
+
+ if (sigaltstack (&ss, NULL) == 0)
+ sa.sa_flags |= SA_ONSTACK;
+ }
+ }
+
if (sigs == NULL)
sigaction (SIGSEGV, &sa, NULL);
else if (sigs[0] == '\0')
@@ -190,21 +207,5 @@
#endif
INSTALL_FOR_SIG (SIGABRT, "abrt");
INSTALL_FOR_SIG (SIGFPE, "fpe");
- }
-
- /* Maybe we are expected to use an alternative stack. */
- if (getenv ("SEGFAULT_USE_ALTSTACK") != 0)
- {
- void *stack_mem = malloc (2 * SIGSTKSZ);
- struct sigaltstack ss;
-
- if (stack_mem != NULL)
- {
- ss.ss_sp = stack_mem;
- ss.ss_flags = SS_ONSTACK;
- ss.ss_size = 2 * SIGSTKSZ;
-
- sigaltstack (&ss, NULL);
- }
}
}