Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/lib/libpthread Support _malloc_thread_cleanup to avoid...
details: https://anonhg.NetBSD.org/src-all/rev/3f0b3a704709
branches: trunk
changeset: 933777:3f0b3a704709
user: Joerg Sonnenberger <joerg%bec.de@localhost>
date: Wed May 27 23:20:34 2020 +0200
description:
Support _malloc_thread_cleanup to avoid possible reentrancy issues for
pthread_specific.
diffstat:
external/bsd/jemalloc/dist/src/tsd.c | 4 ++++
external/bsd/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h | 2 +-
lib/libpthread/pthread.c | 9 ++++++++-
3 files changed, 13 insertions(+), 2 deletions(-)
diffs (59 lines):
diff -r ca99573cd9b2 -r 3f0b3a704709 external/bsd/jemalloc/dist/src/tsd.c
--- a/external/bsd/jemalloc/dist/src/tsd.c Sun May 24 02:56:55 2020 +0200
+++ b/external/bsd/jemalloc/dist/src/tsd.c Wed May 27 23:20:34 2020 +0200
@@ -169,6 +169,10 @@
a0dalloc(wrapper);
}
+__BEGIN_DECLS
+void _malloc_thread_cleanup(void);
+__END_DECLS
+
#if defined(JEMALLOC_MALLOC_THREAD_CLEANUP) || defined(_WIN32)
#ifndef _WIN32
JEMALLOC_EXPORT
diff -r ca99573cd9b2 -r 3f0b3a704709 external/bsd/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h
--- a/external/bsd/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h Sun May 24 02:56:55 2020 +0200
+++ b/external/bsd/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h Wed May 27 23:20:34 2020 +0200
@@ -138,7 +138,7 @@
* _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in
* malloc_tsd.
*/
-/* #undef JEMALLOC_MALLOC_THREAD_CLEANUP */
+#define JEMALLOC_MALLOC_THREAD_CLEANUP
/*
* Defined if threaded initialization is known to be safe on this platform.
diff -r ca99573cd9b2 -r 3f0b3a704709 lib/libpthread/pthread.c
--- a/lib/libpthread/pthread.c Sun May 24 02:56:55 2020 +0200
+++ b/lib/libpthread/pthread.c Wed May 27 23:20:34 2020 +0200
@@ -66,6 +66,10 @@
#include "pthread_makelwp.h"
#include "reentrant.h"
+__BEGIN_DECLS
+void _malloc_thread_cleanup(void) __weak;
+__END_DECLS
+
pthread_rwlock_t pthread__alltree_lock = PTHREAD_RWLOCK_INITIALIZER;
static rb_tree_t pthread__alltree;
@@ -101,7 +105,7 @@
DIAGASSERT_SYSLOG = 1<<2
};
-static int pthread__diagassert;
+static int pthread__diagassert = DIAGASSERT_ABORT | DIAGASSERT_SYSLOG | DIAGASSERT_STDERR;
int pthread__concurrency;
int pthread__nspins;
@@ -694,6 +698,9 @@
/* Perform cleanup of thread-specific data */
pthread__destroy_tsd(self);
+ if (_malloc_thread_cleanup)
+ _malloc_thread_cleanup();
+
/*
* Signal our exit. Our stack and pthread_t won't be reused until
* pthread_create() can see from kernel info that this LWP is gone.
Home |
Main Index |
Thread Index |
Old Index