From: Tom Hughes Date: Sat, 14 Aug 2004 15:37:59 +0000 (+0000) Subject: Maek init_global_thread_specific_state as a constructor to try and ensure X-Git-Tag: svn/VALGRIND_2_2_0~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42c7adce4540f9879533bb1ad25c3d29ff1e5c2c;p=thirdparty%2Fvalgrind.git Maek init_global_thread_specific_state as a constructor to try and ensure that it is called as soon as libpthread.so is loaded even if pthread_create is never called. This ensures that pthread_exit will work correctly, and I think will also cure the famous memory leak in the pthread specifics for the main thread. CCMAIL: 86730-done@bugs.kde.org git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2584 --- diff --git a/corecheck/tests/Makefile.am b/corecheck/tests/Makefile.am index 8df94dcec0..dbfa7f5769 100644 --- a/corecheck/tests/Makefile.am +++ b/corecheck/tests/Makefile.am @@ -23,6 +23,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \ pth_cvsimple.stderr.exp pth_cvsimple.stdout.exp pth_cvsimple.vgtest \ pth_empty.stderr.exp pth_empty.vgtest \ pth_exit.stderr.exp pth_exit.vgtest \ + pth_exit2.stderr.exp pth_exit2.vgtest \ pth_mutexspeed.stderr.exp \ pth_mutexspeed.stdout.exp pth_mutexspeed.vgtest \ pth_once.stderr.exp pth_once.stdout.exp pth_once.vgtest \ @@ -35,7 +36,7 @@ check_PROGRAMS = \ fdleak_fcntl fdleak_ipv4 fdleak_open fdleak_pipe \ fdleak_socketpair sigkill res_search \ pth_atfork1 pth_cancel1 pth_cancel2 pth_cvsimple pth_empty \ - pth_exit pth_mutexspeed pth_once \ + pth_exit pth_exit2 pth_mutexspeed pth_once \ as_mmap as_shm \ vgprintf @@ -73,6 +74,8 @@ pth_empty_SOURCES = pth_empty.c pth_empty_LDADD = -lpthread pth_exit_SOURCES = pth_exit.c pth_exit_LDADD = -lpthread +pth_exit2_SOURCES = pth_exit2.c +pth_exit2_LDADD = -lpthread pth_mutexspeed_SOURCES = pth_mutexspeed.c pth_mutexspeed_LDADD = -lpthread pth_once_SOURCES = pth_once.c diff --git a/corecheck/tests/pth_exit2.c b/corecheck/tests/pth_exit2.c new file mode 100644 index 0000000000..e1b9e7ee0e --- /dev/null +++ b/corecheck/tests/pth_exit2.c @@ -0,0 +1,6 @@ +#include + +int main() +{ + pthread_exit(0); +} diff --git a/corecheck/tests/pth_exit2.stderr.exp b/corecheck/tests/pth_exit2.stderr.exp new file mode 100644 index 0000000000..d18786f806 --- /dev/null +++ b/corecheck/tests/pth_exit2.stderr.exp @@ -0,0 +1,3 @@ + + +ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) diff --git a/corecheck/tests/pth_exit2.vgtest b/corecheck/tests/pth_exit2.vgtest new file mode 100644 index 0000000000..1a5457904d --- /dev/null +++ b/corecheck/tests/pth_exit2.vgtest @@ -0,0 +1 @@ +prog: pth_exit2 diff --git a/coregrind/vg_libpthread.c b/coregrind/vg_libpthread.c index c76c530c2d..55f9e3e07c 100644 --- a/coregrind/vg_libpthread.c +++ b/coregrind/vg_libpthread.c @@ -2019,7 +2019,7 @@ void cleanup_root(void *arg) /* NOTREACHED */ } -static void +static void __attribute__((constructor)) init_global_thread_specific_state ( void ) { int res;