git: libc and pthreads - Fix atfork issues with nmalloc, update dmalloc

Matthew Dillon dillon at crater.dragonflybsd.org
Wed Nov 8 11:07:30 PST 2017


commit e2caf0e77d5adc5ddec07633ec1c9ceaae464acf
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Wed Nov 8 10:56:06 2017 -0800

    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

Summary of changes:
 lib/libc/include/libc_private.h                    |   3 +
 lib/libc/stdlib/Symbol.map                         |   3 +
 lib/libc/stdlib/dmalloc.c                          | 365 +++++++++++++++------
 lib/libc/stdlib/nmalloc.c                          |  62 +++-
 lib/libthread_xu/thread/Makefile.inc               |   1 +
 lib/libthread_xu/thread/thr_init.c                 |   1 +
 .../libthread_xu/thread/thr_malloc.c               |  34 +-
 lib/libthread_xu/thread/thr_private.h              |   1 +
 8 files changed, 333 insertions(+), 137 deletions(-)
 copy usr.bin/kcollect/kcollect.h => lib/libthread_xu/thread/thr_malloc.c (79%)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e2caf0e77d5adc5ddec07633ec1c9ceaae464acf


-- 
DragonFly BSD source repository



More information about the Commits mailing list