git: pthreads - Use mmap() for thread->specific data

Matthew Dillon dillon at crater.dragonflybsd.org
Mon Jul 1 17:16:55 PDT 2019


commit 8356845aa7f8204ed31a0d91faea4d58a1cb93a0
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Mon Jul 1 10:15:41 2019 -0700

    pthreads - Use mmap() for thread->specific data
    
    * Any application which tries to replace malloc() can wind up causing
      pthreads to implode due to its use of malloc() in the early thread
      initialization code.
    
    * Change pthread_setspecific() to use mmap() instead of malloc()
      to allocate the per-thread keys array, allowing applications
      which replace malloc() to use pthread_setspecific() to initialize
      per-thread malloc data if so desired.
    
      The use of pthread_setspecific() predates TLS (per-thread) variable
      declarations, aka the __thread storage qualifier, which is the
      better way to implement per-thread data, but it is still a reasonable
      choice so make it work.
    
    * For DragonFlyBSD this is not expected to improve chrome because
      our chrome build uses our base malloc() and does not try to replace
      it with tcmalloc().  However, this change might help a limited
      number of other applications that do.
    
    Reported-by: sephe, tuxillo

Summary of changes:
 lib/libthread_xu/thread/thr_private.h |  1 +
 lib/libthread_xu/thread/thr_spec.c    | 44 ++++++++++++++++++++++++-----------
 2 files changed, 31 insertions(+), 14 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/8356845aa7f8204ed31a0d91faea4d58a1cb93a0


-- 
DragonFly BSD source repository



More information about the Commits mailing list