Skip to content

Commit 7719ae6

Browse files
committed
Bug#18913935: REMOVE SUPPORT FOR LINUXTHREADS
This patch removes support for LinuxThreads. It was superseded by NPTL in Linux 2.6 (2003). Partial backport of Bug#17007529 from 5.7 to 5.6.
1 parent c08c6b5 commit 7719ae6

9 files changed

Lines changed: 6 additions & 327 deletions

File tree

cmake/os/Linux.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ INCLUDE(CheckSymbolExists)
2020

2121
# Something that needs to be set on legacy reasons
2222
SET(TARGET_OS_LINUX 1)
23-
SET(HAVE_NPTL 1)
2423
SET(_GNU_SOURCE 1)
2524

2625
# Fix CMake (< 2.8) flags. -rdynamic exports too many symbols.

config.h.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@
188188
#cmakedefine HAVE_LSTAT 1
189189
#cmakedefine HAVE_MEMALIGN 1
190190
/* #cmakedefine HAVE_MLOCK 1 see Bug#54662 */
191-
#cmakedefine HAVE_NPTL 1
192191
#cmakedefine HAVE_NL_LANGINFO 1
193192
#cmakedefine HAVE_MADVISE 1
194193
#cmakedefine HAVE_DECL_MADVISE 1

include/my_pthread.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -853,18 +853,7 @@ extern void **my_thread_var_dbug();
853853
extern uint my_thread_end_wait_time;
854854
#define my_thread_var (_my_thread_var())
855855
#define my_errno my_thread_var->thr_errno
856-
/*
857-
Keep track of shutdown,signal, and main threads so that my_end() will not
858-
report errors with them
859-
*/
860-
861-
/* Which kind of thread library is in use */
862-
863-
#define THD_LIB_OTHER 1
864-
#define THD_LIB_NPTL 2
865-
#define THD_LIB_LT 4
866856

867-
extern uint thd_lib_detected;
868857

869858
/*
870859
thread_safe_xxx functions are for critical statistic or counters.

mysql-test/valgrind.supp

Lines changed: 0 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -497,200 +497,6 @@
497497
fun:dlopen*
498498
}
499499

500-
#
501-
# BUG#45630
502-
# Suppress valgrind failures within nptl_pthread_exit_hack_handler on Ubuntu 9.04, x86 (but not amd64)
503-
#
504-
505-
{
506-
Mem loss within nptl_pthread_exit_hack_handler 1
507-
Memcheck:Leak
508-
fun:malloc
509-
obj:*/ld-*.so
510-
obj:*/ld-*.so
511-
obj:*/ld-*.so
512-
obj:*/ld-*.so
513-
obj:*/ld-*.so
514-
obj:*/libc-*.so
515-
obj:*/ld-*.so
516-
fun:__libc_dlopen_mode
517-
fun:pthread_cancel_init
518-
fun:_Unwind_ForcedUnwind
519-
fun:__pthread_unwind
520-
fun:pthread_exit
521-
fun:nptl_pthread_exit_hack_handler
522-
fun:start_thread
523-
fun:clone
524-
}
525-
526-
{
527-
Mem loss within nptl_pthread_exit_hack_handler 2
528-
Memcheck:Leak
529-
fun:malloc
530-
obj:*/ld-*.so
531-
obj:*/ld-*.so
532-
obj:*/ld-*.so
533-
obj:*/ld-*.so
534-
obj:*/libc-*.so
535-
obj:*/ld-*.so
536-
fun:__libc_dlopen_mode
537-
fun:pthread_cancel_init
538-
fun:_Unwind_ForcedUnwind
539-
fun:__pthread_unwind
540-
fun:pthread_exit
541-
fun:nptl_pthread_exit_hack_handler
542-
fun:start_thread
543-
fun:clone
544-
}
545-
546-
{
547-
Mem loss within nptl_pthread_exit_hack_handler 3
548-
Memcheck:Leak
549-
fun:calloc
550-
obj:*/ld-*.so
551-
obj:*/ld-*.so
552-
obj:*/ld-*.so
553-
obj:*/ld-*.so
554-
obj:*/libc-*.so
555-
obj:*/ld-*.so
556-
fun:__libc_dlopen_mode
557-
fun:pthread_cancel_init
558-
fun:_Unwind_ForcedUnwind
559-
fun:__pthread_unwind
560-
fun:pthread_exit
561-
fun:nptl_pthread_exit_hack_handler
562-
fun:start_thread
563-
fun:clone
564-
}
565-
566-
{
567-
Mem loss within nptl_pthread_exit_hack_handler 4
568-
Memcheck:Leak
569-
fun:malloc
570-
obj:*/ld-*.so
571-
obj:*/ld-*.so
572-
obj:*/ld-*.so
573-
obj:*/ld-*.so
574-
obj:*/ld-*.so
575-
obj:*/ld-*.so
576-
obj:*/libc-*.so
577-
obj:*/ld-*.so
578-
fun:__libc_dlopen_mode
579-
fun:pthread_cancel_init
580-
fun:_Unwind_ForcedUnwind
581-
fun:__pthread_unwind
582-
fun:pthread_exit
583-
fun:nptl_pthread_exit_hack_handler
584-
fun:start_thread
585-
}
586-
587-
{
588-
Mem loss within nptl_pthread_exit_hack_handler 5
589-
Memcheck:Leak
590-
fun:calloc
591-
obj:*/ld-*.so
592-
obj:*/ld-*.so
593-
obj:*/ld-*.so
594-
obj:*/ld-*.so
595-
obj:*/ld-*.so
596-
obj:*/ld-*.so
597-
obj:*/libc-*.so
598-
obj:*/ld-*.so
599-
fun:__libc_dlopen_mode
600-
fun:pthread_cancel_init
601-
fun:_Unwind_ForcedUnwind
602-
fun:__pthread_unwind
603-
fun:pthread_exit
604-
fun:nptl_pthread_exit_hack_handler
605-
fun:start_thread
606-
}
607-
608-
# suppressions for glibc 2.6.1 64 bit
609-
610-
{
611-
Mem loss within nptl_pthread_exit_hack_handler 6
612-
Memcheck:Leak
613-
fun:malloc
614-
obj:*/ld-*.so
615-
obj:*/ld-*.so
616-
obj:*/ld-*.so
617-
obj:*/ld-*.so
618-
obj:*/ld-*.so
619-
obj:*/ld-*.so
620-
obj:*/libc-*.so
621-
obj:*/ld-*.so
622-
obj:*/libc-*.so
623-
fun:__libc_dlopen_mode
624-
fun:pthread_cancel_init
625-
fun:_Unwind_ForcedUnwind
626-
fun:__pthread_unwind
627-
fun:pthread_exit
628-
fun:nptl_pthread_exit_hack_handler
629-
}
630-
631-
{
632-
Mem loss within nptl_pthread_exit_hack_handler 7
633-
Memcheck:Leak
634-
fun:malloc
635-
obj:*/ld-*.so
636-
obj:*/ld-*.so
637-
obj:*/ld-*.so
638-
obj:*/ld-*.so
639-
obj:*/libc-*.so
640-
obj:*/ld-*.so
641-
obj:*/libc-*.so
642-
fun:__libc_dlopen_mode
643-
fun:pthread_cancel_init
644-
fun:_Unwind_ForcedUnwind
645-
fun:__pthread_unwind
646-
fun:pthread_exit
647-
fun:nptl_pthread_exit_hack_handler
648-
fun:start_thread
649-
fun:clone
650-
}
651-
652-
{
653-
Mem loss within nptl_pthread_exit_hack_handler 8
654-
Memcheck:Leak
655-
fun:calloc
656-
obj:*/ld-*.so
657-
obj:*/ld-*.so
658-
obj:*/ld-*.so
659-
obj:*/ld-*.so
660-
obj:*/libc-*.so
661-
obj:*/ld-*.so
662-
obj:*/libc-*.so
663-
fun:__libc_dlopen_mode
664-
fun:pthread_cancel_init
665-
fun:_Unwind_ForcedUnwind
666-
fun:__pthread_unwind
667-
fun:pthread_exit
668-
fun:nptl_pthread_exit_hack_handler
669-
fun:start_thread
670-
fun:clone
671-
}
672-
673-
{
674-
Mem loss within nptl_pthread_exit_hack_handler 8
675-
Memcheck:Leak
676-
fun:calloc
677-
obj:*/ld-*.so
678-
obj:*/ld-*.so
679-
obj:*/ld-*.so
680-
obj:*/ld-*.so
681-
obj:*/ld-*.so
682-
obj:*/ld-*.so
683-
obj:*/libc-*.so
684-
obj:*/ld-*.so
685-
obj:*/libc-*.so
686-
fun:__libc_dlopen_mode
687-
fun:pthread_cancel_init
688-
fun:_Unwind_ForcedUnwind
689-
fun:__pthread_unwind
690-
fun:pthread_exit
691-
fun:nptl_pthread_exit_hack_handler
692-
}
693-
694500
#
695501
# Pthread doesn't free all thread specific memory before program exists
696502
#

mysys/my_pthread.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#define SCHED_POLICY SCHED_OTHER
2929
#endif
3030

31-
uint thd_lib_detected= 0;
32-
3331
/* To allow use of pthread_getspecific with two arguments */
3432

3533
#ifdef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC

mysys/my_thr_init.c

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,7 @@ pthread_mutexattr_t my_errorcheck_mutexattr;
4444
#ifdef _MSC_VER
4545
static void install_sigabrt_handler();
4646
#endif
47-
#ifdef TARGET_OS_LINUX
4847

49-
/*
50-
Dummy thread spawned in my_thread_global_init() below to avoid
51-
race conditions in NPTL pthread_exit code.
52-
*/
53-
54-
static pthread_handler_t
55-
nptl_pthread_exit_hack_handler(void *arg __attribute((unused)))
56-
{
57-
/* Do nothing! */
58-
pthread_exit(0);
59-
return 0;
60-
}
61-
62-
#endif /* TARGET_OS_LINUX */
63-
64-
65-
static uint get_thread_lib(void);
6648

6749
/** True if @c my_thread_global_init() has been called. */
6850
static my_bool my_thread_global_init_done= 0;
@@ -179,35 +161,6 @@ my_bool my_thread_global_init(void)
179161
if (my_thread_init())
180162
return 1;
181163

182-
thd_lib_detected= get_thread_lib();
183-
184-
#ifdef TARGET_OS_LINUX
185-
/*
186-
BUG#24507: Race conditions inside current NPTL pthread_exit()
187-
implementation.
188-
189-
To avoid a possible segmentation fault during concurrent
190-
executions of pthread_exit(), a dummy thread is spawned which
191-
initializes internal variables of pthread lib. See bug description
192-
for a full explanation.
193-
194-
TODO: Remove this code when fixed versions of glibc6 are in common
195-
use.
196-
*/
197-
if (thd_lib_detected == THD_LIB_NPTL)
198-
{
199-
pthread_t dummy_thread;
200-
pthread_attr_t dummy_thread_attr;
201-
202-
pthread_attr_init(&dummy_thread_attr);
203-
pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_JOINABLE);
204-
205-
if (pthread_create(&dummy_thread,&dummy_thread_attr,
206-
nptl_pthread_exit_hack_handler, NULL) == 0)
207-
(void)pthread_join(dummy_thread, NULL);
208-
}
209-
#endif /* TARGET_OS_LINUX */
210-
211164
mysql_mutex_init(key_THR_LOCK_lock, &THR_LOCK_lock, MY_MUTEX_INIT_FAST);
212165
mysql_mutex_init(key_THR_LOCK_myisam, &THR_LOCK_myisam, MY_MUTEX_INIT_SLOW);
213166
mysql_mutex_init(key_THR_LOCK_myisam_mmap, &THR_LOCK_myisam_mmap, MY_MUTEX_INIT_FAST);
@@ -490,21 +443,6 @@ extern void **my_thread_var_dbug()
490443
#endif /* DBUG_OFF */
491444

492445

493-
static uint get_thread_lib(void)
494-
{
495-
#ifdef _CS_GNU_LIBPTHREAD_VERSION
496-
char buff[64];
497-
498-
confstr(_CS_GNU_LIBPTHREAD_VERSION, buff, sizeof(buff));
499-
500-
if (!strncasecmp(buff, "NPTL", 4))
501-
return THD_LIB_NPTL;
502-
if (!strncasecmp(buff, "linuxthreads", 12))
503-
return THD_LIB_LT;
504-
#endif
505-
return THD_LIB_OTHER;
506-
}
507-
508446
#ifdef _WIN32
509447
/*
510448
In Visual Studio 2005 and later, default SIGABRT handler will overwrite

mysys/thr_alarm.c

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,8 @@ void init_thr_alarm(uint max_alarms)
8080
sigfillset(&full_signal_set); /* Neaded to block signals */
8181
mysql_mutex_init(key_LOCK_alarm, &LOCK_alarm, MY_MUTEX_INIT_FAST);
8282
mysql_cond_init(key_COND_alarm, &COND_alarm, NULL);
83-
if (thd_lib_detected == THD_LIB_LT)
84-
thr_client_alarm= SIGALRM;
85-
else
86-
thr_client_alarm= SIGUSR1;
87-
#ifndef USE_ALARM_THREAD
88-
if (thd_lib_detected != THD_LIB_LT)
89-
#endif
90-
{
91-
my_sigset(thr_client_alarm, thread_alarm);
92-
}
83+
thr_client_alarm= SIGUSR1;
84+
my_sigset(thr_client_alarm, thread_alarm);
9385
sigemptyset(&s);
9486
sigaddset(&s, THR_SERVER_ALARM);
9587
alarm_thread=pthread_self();
@@ -106,11 +98,6 @@ void init_thr_alarm(uint max_alarms)
10698
}
10799
#elif defined(USE_ONE_SIGNAL_HAND)
108100
pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
109-
if (thd_lib_detected == THD_LIB_LT)
110-
{
111-
my_sigset(thr_client_alarm, process_alarm); /* Linuxthreads */
112-
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
113-
}
114101
#else
115102
my_sigset(THR_SERVER_ALARM, process_alarm);
116103
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
@@ -294,18 +281,6 @@ sig_handler process_alarm(int sig __attribute__((unused)))
294281
This must be first as we can't call DBUG inside an alarm for a normal thread
295282
*/
296283

297-
if (thd_lib_detected == THD_LIB_LT &&
298-
!pthread_equal(pthread_self(),alarm_thread))
299-
{
300-
#if defined(MAIN) && !defined(__bsdi__)
301-
printf("thread_alarm in process_alarm\n"); fflush(stdout);
302-
#endif
303-
#ifdef SIGNAL_HANDLER_RESET_ON_DELIVERY
304-
my_sigset(thr_client_alarm, process_alarm); /* int. thread system calls */
305-
#endif
306-
return;
307-
}
308-
309284
/*
310285
We have to do do the handling of the alarm in a sub function,
311286
because otherwise we would get problems with two threads calling

0 commit comments

Comments
 (0)