summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libc')
-rw-r--r--usr/src/lib/libc/port/threads/thr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/usr/src/lib/libc/port/threads/thr.c b/usr/src/lib/libc/port/threads/thr.c
index 134c078a57..747e789442 100644
--- a/usr/src/lib/libc/port/threads/thr.c
+++ b/usr/src/lib/libc/port/threads/thr.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016 by Delphix. All rights reserved.
+ * Copyright (c) 2017 by The MathWorks, Inc. All rights reserved.
*/
/*
* Copyright 2016 Joyent, Inc.
@@ -779,9 +780,14 @@ _thrp_exit()
}
lmutex_unlock(&udp->link_lock);
- tmem_exit(); /* deallocate tmem allocations */
+ /*
+ * tsd_exit() may call its destructor free(), thus depending on
+ * tmem, therefore tmem_exit() needs to be called after tsd_exit()
+ * and tls_exit().
+ */
tsd_exit(); /* deallocate thread-specific data */
tls_exit(); /* deallocate thread-local storage */
+ tmem_exit(); /* deallocate tmem allocations */
heldlock_exit(); /* deal with left-over held locks */
/* block all signals to finish exiting */