Print this page
8276 rpcbind leaks memory due to libumem per thread caching.
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>

@@ -20,10 +20,11 @@
  */
 
 /*
  * 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.
  */
 

@@ -775,13 +776,18 @@
                 exit(0);
                 thr_panic("_thrp_exit(): exit(0) returned");
         }
         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 */
         block_all_signals(self);
         /* also prevent ourself from being suspended */