libc - Fix some recursion issues during thread teardown
commit6c4de62c59ba95420ee712e340c8dd8d0ab4b1f9
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 4 Oct 2010 18:35:48 +0000 (4 11:35 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 4 Oct 2010 18:35:48 +0000 (4 11:35 -0700)
tree59a01d910ad239b350e9aa7e15e212e5c8b27e8e
parent42033fe6ad16e28f126c32e3a7f1657c60c3c382
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.
lib/libc/include/libc_private.h
lib/libc/stdlib/nmalloc.c
lib/libthread_xu/thread/thr_create.c