Remove initialization of the non-TLS tsd wrapper from static memory
Using static memory when malloc_tsd_malloc fails means all threads share the same wrapper and thus the same wrapped value. This defeats the purpose of TSD.
This commit is contained in:
parent
7ff1ce4131
commit
8ad483fe60
@ -192,7 +192,6 @@ a_name##_tsd_set(a_type *val) \
|
|||||||
a_cleanup) \
|
a_cleanup) \
|
||||||
/* Data structure. */ \
|
/* Data structure. */ \
|
||||||
typedef struct { \
|
typedef struct { \
|
||||||
bool isstatic; \
|
|
||||||
bool initialized; \
|
bool initialized; \
|
||||||
a_type val; \
|
a_type val; \
|
||||||
} a_name##_tsd_wrapper_t; \
|
} a_name##_tsd_wrapper_t; \
|
||||||
@ -218,8 +217,7 @@ a_name##_tsd_cleanup_wrapper(void *arg) \
|
|||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
if (wrapper->isstatic == false) \
|
malloc_tsd_dalloc(wrapper); \
|
||||||
malloc_tsd_dalloc(wrapper); \
|
|
||||||
} \
|
} \
|
||||||
a_attr bool \
|
a_attr bool \
|
||||||
a_name##_tsd_boot(void) \
|
a_name##_tsd_boot(void) \
|
||||||
@ -242,17 +240,11 @@ a_name##_tsd_get_wrapper(void) \
|
|||||||
wrapper = (a_name##_tsd_wrapper_t *) \
|
wrapper = (a_name##_tsd_wrapper_t *) \
|
||||||
malloc_tsd_malloc(sizeof(a_name##_tsd_wrapper_t)); \
|
malloc_tsd_malloc(sizeof(a_name##_tsd_wrapper_t)); \
|
||||||
if (wrapper == NULL) { \
|
if (wrapper == NULL) { \
|
||||||
static a_name##_tsd_wrapper_t \
|
|
||||||
a_name##_tsd_static_data = \
|
|
||||||
{true, false, a_initializer}; \
|
|
||||||
malloc_write("<jemalloc>: Error allocating" \
|
malloc_write("<jemalloc>: Error allocating" \
|
||||||
" TSD for "#a_name"\n"); \
|
" TSD for "#a_name"\n"); \
|
||||||
if (opt_abort) \
|
abort(); \
|
||||||
abort(); \
|
|
||||||
wrapper = &a_name##_tsd_static_data; \
|
|
||||||
} else { \
|
} else { \
|
||||||
static a_type tsd_static_data = a_initializer; \
|
static a_type tsd_static_data = a_initializer; \
|
||||||
wrapper->isstatic = false; \
|
|
||||||
wrapper->initialized = false; \
|
wrapper->initialized = false; \
|
||||||
wrapper->val = tsd_static_data; \
|
wrapper->val = tsd_static_data; \
|
||||||
} \
|
} \
|
||||||
@ -260,8 +252,7 @@ a_name##_tsd_get_wrapper(void) \
|
|||||||
(void *)wrapper)) { \
|
(void *)wrapper)) { \
|
||||||
malloc_write("<jemalloc>: Error setting" \
|
malloc_write("<jemalloc>: Error setting" \
|
||||||
" TSD for "#a_name"\n"); \
|
" TSD for "#a_name"\n"); \
|
||||||
if (opt_abort) \
|
abort(); \
|
||||||
abort(); \
|
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
return (wrapper); \
|
return (wrapper); \
|
||||||
|
Loading…
Reference in New Issue
Block a user