summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <tsmith@siva.hindu.god>2007-01-18 10:06:36 -0700
committerunknown <tsmith@siva.hindu.god>2007-01-18 10:06:36 -0700
commite594d61625b09e50a9fa3bb3d7d666de7e6702b1 (patch)
treeb9862a98b8c3fd2a9f8986b6fe8bf6fd645bd836 /mysys
parent9a765037043f62cc8dd419517b90d520fedc99dd (diff)
parent8f1593431fe1ee10fa3d19917b236bdab947276b (diff)
downloadmariadb-git-e594d61625b09e50a9fa3bb3d7d666de7e6702b1.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 client/mysqlbinlog.cc: Auto merged include/my_pthread.h: Auto merged mysql-test/r/sp.result: Auto merged mysql-test/t/mix_innodb_myisam_binlog.test: Auto merged mysql-test/t/sp.test: Auto merged sql/mysqld.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_parse.cc: Manual merge
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_thr_init.c39
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
/*