summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_init.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2000-11-14 20:00:19 +0000
committerdeischen <deischen@FreeBSD.org>2000-11-14 20:00:19 +0000
commit5ed7dea44c3c8564f41807299e6844d6d3adc3fe (patch)
tree72b03470b2ccceba1843c58253e889d8fb340d45 /lib/libpthread/thread/thr_init.c
parent5f42d57882aa1072ce12350297665532c3ad1b61 (diff)
downloadFreeBSD-src-5ed7dea44c3c8564f41807299e6844d6d3adc3fe.zip
FreeBSD-src-5ed7dea44c3c8564f41807299e6844d6d3adc3fe.tar.gz
When entering the scheduler from the signal handler, tell
the kernel to (re)use the alternate signal stack. In this case, we don't return normally from the signal handler, so the kernel still thinks we are using the signal stack. The fixes a nasty bug where the signal handler can start fiddling with the stack of a thread while the handler is actually running on the same stack. MFC candidate
Diffstat (limited to 'lib/libpthread/thread/thr_init.c')
-rw-r--r--lib/libpthread/thread/thr_init.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c
index 35731c4..be671a1 100644
--- a/lib/libpthread/thread/thr_init.c
+++ b/lib/libpthread/thread/thr_init.c
@@ -92,7 +92,6 @@ _thread_init(void)
int mib[2];
struct clockinfo clockinfo;
struct sigaction act;
- struct sigaltstack alt;
/* Check if this function has already been called: */
if (_thread_initial)
@@ -281,11 +280,15 @@ _thread_init(void)
/* Clear the signal queue: */
memset(_thread_sigq, 0, sizeof(_thread_sigq));
- /* Create and install an alternate signal stack: */
- alt.ss_sp = malloc(SIGSTKSZ); /* recommended stack size */
- alt.ss_size = SIGSTKSZ;
- alt.ss_flags = 0;
- if (_thread_sys_sigaltstack(&alt, NULL) != 0)
+ /*
+ * Create and install an alternate signal stack of
+ * the recommended size:
+ */
+ _thread_sigstack.ss_sp = malloc(SIGSTKSZ);
+ _thread_sigstack.ss_size = SIGSTKSZ;
+ _thread_sigstack.ss_flags = 0;
+ if ((_thread_sigstack.ss_sp == NULL) ||
+ (_thread_sys_sigaltstack(&_thread_sigstack, NULL) != 0))
PANIC("Unable to install alternate signal stack");
/* Enter a loop to get the existing signal status: */
OpenPOWER on IntegriCloud