libc and pthreads - Fix atfork issues with nmalloc, update dmalloc
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 8 Nov 2017 18:56:06 +0000 (10:56 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 8 Nov 2017 18:56:06 +0000 (10:56 -0800)
commite2caf0e77d5adc5ddec07633ec1c9ceaae464acf
tree055523179be0dd59f471ead3c29b6fe0b4273190
parentf554ca21dcb97a996e96a97550bc26b52367656a
libc and pthreads - Fix atfork issues with nmalloc, update dmalloc

* Implement atfork handling for nmalloc.  As part of this, refactor
  some of nmalloc.

* Remove ZERO_LENGTH_PTR from nmalloc.  Instead, force 0-byte
  allocations to allocate 1 byte.  The standard requires unique
  pointers to be returned.

* For now go back to a single depot lock instead of a per-zone
  lock.  It is unclear whether multi-threaded performance will
  suffer or not, but its the only way to implement atfork handling.

* Implement proper atfork interlocks for nmalloc via pthreads to avoid
  corruption when heavily threaded programs call fork().

* Bring dmalloc up to date in various ways, including properly
  implementing a minimum 16-byte alignment for allocations >= 16 bytes,
  and atfork handling.  Also use a global depot lock for the same
  reason we use it in nmalloc, and implement a front-end magazine
  shortcut for any allocations <= 2MB.

Reported-by: mneumann
lib/libc/include/libc_private.h
lib/libc/stdlib/Symbol.map
lib/libc/stdlib/dmalloc.c
lib/libc/stdlib/nmalloc.c
lib/libthread_xu/thread/Makefile.inc
lib/libthread_xu/thread/thr_init.c
lib/libthread_xu/thread/thr_malloc.c [new file with mode: 0644]
lib/libthread_xu/thread/thr_private.h