aboutsummaryrefslogtreecommitdiff
path: root/lib/libpthread
diff options
context:
space:
mode:
authorJohn Birrell <jb@FreeBSD.org>1998-06-09 23:08:41 +0000
committerJohn Birrell <jb@FreeBSD.org>1998-06-09 23:08:41 +0000
commit74ebed9424bafa673c7f646b48f845cf035c6a71 (patch)
treee899f7f37cda0d2b605840485dcfced7f56f9c32 /lib/libpthread
parent27949f44dce35720bd2aecc609a9605a0f4c7369 (diff)
downloadsrc-74ebed9424bafa673c7f646b48f845cf035c6a71.tar.gz
src-74ebed9424bafa673c7f646b48f845cf035c6a71.zip
POSIX says that pthread_exit() is not allowed to be called from a
cleanup destructor, so trap this case to prevent me from being being burnt again by applications that try to do this. With this change, an application (like one using a mis-configured ACE) will exit the process after displaying a message quoting the POSIX section that the application has violated.
Notes
Notes: svn path=/head/; revision=36827
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/thread/thr_exit.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/libpthread/thread/thr_exit.c b/lib/libpthread/thread/thr_exit.c
index 4bc7da90bf1f..0083f2b01694 100644
--- a/lib/libpthread/thread/thr_exit.c
+++ b/lib/libpthread/thread/thr_exit.c
@@ -102,6 +102,16 @@ pthread_exit(void *status)
long l;
pthread_t pthread;
+ /* Check if this thread is already in the process of exiting: */
+ if ((_thread_run->flags & PTHREAD_EXITING) != 0) {
+ char msg[128];
+ snprintf(msg,"Thread %p has called pthread_exit() from a destructor. POSIX 1003.1 1996 s16.2.5.2 does not allow this!",_thread_run);
+ PANIC(msg);
+ }
+
+ /* Flag this thread as exiting: */
+ _thread_run->flags |= PTHREAD_EXITING;
+
/* Save the return value: */
_thread_run->ret = status;