diff options
author | tsmith@siva.hindu.god <> | 2007-01-18 10:06:36 -0700 |
---|---|---|
committer | tsmith@siva.hindu.god <> | 2007-01-18 10:06:36 -0700 |
commit | 244b2004eeac45c514f731ae14880159b0e16807 (patch) | |
tree | b9862a98b8c3fd2a9f8986b6fe8bf6fd645bd836 /mysys | |
parent | 2ae081e041dfe5d7cb60a0663de288d05e4280c4 (diff) | |
parent | d4aa9f0c6227f398aac79682c54717af6398143d (diff) | |
download | mariadb-git-244b2004eeac45c514f731ae14880159b0e16807.tar.gz |
Merge siva.hindu.god:/home/tsmith/m/bk/mrg-jan17/50
into siva.hindu.god:/home/tsmith/m/bk/mrg-jan17/maint/50
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_thr_init.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index b44e5ced99f..c5105dc4e1e 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -46,6 +46,23 @@ pthread_mutexattr_t my_fast_mutexattr; pthread_mutexattr_t my_errorcheck_mutexattr; #endif +#ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */ + +/* + Dummy thread spawned in my_thread_global_init() below to avoid + race conditions in NPTL pthread_exit code. +*/ + +static +pthread_handler_t nptl_pthread_exit_hack_handler(void *arg) +{ + /* Do nothing! */ + pthread_exit(0); + return 0; +} + +#endif + /* initialize thread environment @@ -64,6 +81,28 @@ my_bool my_thread_global_init(void) fprintf(stderr,"Can't initialize threads: error %d\n",errno); return 1; } + +#ifdef NPTL_PTHREAD_EXIT_BUG + +/* + BUG#24507: Race conditions inside current NPTL pthread_exit() implementation. + + To avoid a possible segmentation fault during concurrent executions of + pthread_exit(), a dummy thread is spawned which initializes internal variables + of pthread lib. See bug description for thoroughfull explanation. + + TODO: Remove this code when fixed versions of glibc6 are in common use. +*/ + + pthread_t dummy_thread; + pthread_attr_t dummy_thread_attr; + + pthread_attr_init(&dummy_thread_attr); + pthread_attr_setdetachstate(&dummy_thread_attr,PTHREAD_CREATE_DETACHED); + + pthread_create(&dummy_thread,&dummy_thread_attr,nptl_pthread_exit_hack_handler,NULL); + +#endif #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP /* |