summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2011-01-25 22:55:15 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2011-01-25 22:55:15 +0000
commitf5d4a5634a842edac498a706a0ebda6341acfba5 (patch)
treed4bc333d5972f6b3b2a0a9d6cc8b08a4de0d1a8c
parent0604ff1925048a0139beaea00461164baec912aa (diff)
Make the pthread scheduler block signals while restoring a newly
selected thread's state. Fixes random qemu crashes. ok miod@
-rw-r--r--lib/libpthread/uthread/uthread_kern.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/libpthread/uthread/uthread_kern.c b/lib/libpthread/uthread/uthread_kern.c
index 2956651d191..fabb2088cd8 100644
--- a/lib/libpthread/uthread/uthread_kern.c
+++ b/lib/libpthread/uthread/uthread_kern.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_kern.c,v 1.36 2007/05/21 16:50:36 kurt Exp $ */
+/* $OpenBSD: uthread_kern.c,v 1.37 2011/01/25 22:55:14 stsp Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -440,6 +440,12 @@ _thread_kern_sched(struct sigcontext * scp)
_queue_signals = 0;
}
+ /*
+ * Prevent the signal handler from fiddling with this
+ * thread before its state is set.
+ */
+ _queue_signals = 1;
+
/* Make the selected thread the current thread: */
_set_curthread(pthread_h);
curthread = pthread_h;
@@ -480,6 +486,11 @@ _thread_kern_sched(struct sigcontext * scp)
* before use.
*/
curthread = _get_curthread();
+
+ /* Allow signals again. */
+ _queue_signals = 0;
+
+ /* Done with scheduling. */
_thread_kern_in_sched = 0;
/* run any installed switch-hooks */