git: libc - Fix some recursion issues during thread teardown

Matthew Dillon dillon at crater.dragonflybsd.org
Mon Oct 4 11:56:06 PDT 2010


commit 6c4de62c59ba95420ee712e340c8dd8d0ab4b1f9
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Mon Oct 4 11:35:48 2010 -0700

    libc - Fix some recursion issues during thread teardown
    
    * thread destructors called by sophisticated pthreaded programs such
      as firefox can wind up allocating/freeing space multiple times
      AFTER nmalloc's destructor is run.
    
      This can leave the mtmagazine in a weird state because it's destructor
      fails to NULL-out tp->mags[i].loaded and tp->mags[i].prev.
    
    * Properly NULL out tp->mags[i].{loaded,prev} in the destructor.
    
    * Lockout mtmagazine use while the mtmagazine is being initialized or
      destroyed.
    
    * Permanently lockout mtmagazine use after its destructor has been run.
    
    * Instead of trying to initialize the mtmagazine on the first free, which
      might not occur until the destrutor is run (causing pthreads to complain
      about destructors being left hanging), have libthread_xu call a new
      function _nmalloc_thr_init() during thread creation and do all the slab
      initialization there.

Summary of changes:
 lib/libc/include/libc_private.h      |    1 +
 lib/libc/stdlib/nmalloc.c            |   96 ++++++++++++++++++++++++++--------
 lib/libthread_xu/thread/thr_create.c |    1 +
 3 files changed, 75 insertions(+), 23 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/6c4de62c59ba95420ee712e340c8dd8d0ab4b1f9


-- 
DragonFly BSD source repository





More information about the Commits mailing list