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>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/threads/thr.c
          +++ new/usr/src/lib/libc/port/threads/thr.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright (c) 2016 by Delphix. All rights reserved.
       25 + * Copyright (c) 2017 by The MathWorks, Inc. All rights reserved.
  25   26   */
  26   27  /*
  27   28   * Copyright 2016 Joyent, Inc.
  28   29   */
  29   30  
  30   31  #include "lint.h"
  31   32  #include "thr_uberdata.h"
  32   33  #include <pthread.h>
  33   34  #include <procfs.h>
  34   35  #include <sys/uio.h>
↓ open down ↓ 735 lines elided ↑ open up ↑
 770  771                   * We are the last non-daemon thread exiting.
 771  772                   * Exit the process.  We retain our TSD and TLS so
 772  773                   * that atexit() application functions can use them.
 773  774                   */
 774  775                  lmutex_unlock(&udp->link_lock);
 775  776                  exit(0);
 776  777                  thr_panic("_thrp_exit(): exit(0) returned");
 777  778          }
 778  779          lmutex_unlock(&udp->link_lock);
 779  780  
 780      -        tmem_exit();            /* deallocate tmem allocations */
      781 +        /*
      782 +         * tsd_exit() may call its destructor free(), thus depending on
      783 +         * tmem, therefore tmem_exit() needs to be called after tsd_exit()
      784 +         * and tls_exit().
      785 +         */
 781  786          tsd_exit();             /* deallocate thread-specific data */
 782  787          tls_exit();             /* deallocate thread-local storage */
      788 +        tmem_exit();            /* deallocate tmem allocations */
 783  789          heldlock_exit();        /* deal with left-over held locks */
 784  790  
 785  791          /* block all signals to finish exiting */
 786  792          block_all_signals(self);
 787  793          /* also prevent ourself from being suspended */
 788  794          enter_critical(self);
 789  795          rwl_free(self);
 790  796          lmutex_lock(&udp->link_lock);
 791  797          ulwp_free(self);
 792  798          (void) ulwp_lock(self, udp);
↓ open down ↓ 2077 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX