]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Maek init_global_thread_specific_state as a constructor to try and ensure
authorTom Hughes <tom@compton.nu>
Sat, 14 Aug 2004 15:37:59 +0000 (15:37 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 14 Aug 2004 15:37:59 +0000 (15:37 +0000)
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

corecheck/tests/Makefile.am
corecheck/tests/pth_exit2.c [new file with mode: 0644]
corecheck/tests/pth_exit2.stderr.exp [new file with mode: 0644]
corecheck/tests/pth_exit2.vgtest [new file with mode: 0644]
coregrind/vg_libpthread.c

index 8df94dcec0ee7fcf0ac59678bde30926d6f86f2f..dbfa7f576965d02a2f896a12013d173e144a27cd 100644 (file)
@@ -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 (file)
index 0000000..e1b9e7e
--- /dev/null
@@ -0,0 +1,6 @@
+#include <pthread.h>
+
+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 (file)
index 0000000..d18786f
--- /dev/null
@@ -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 (file)
index 0000000..1a54579
--- /dev/null
@@ -0,0 +1 @@
+prog: pth_exit2
index c76c530c2db14cbceed70a73f0dbd64fae1d2490..55f9e3e07c3f333f46205bba146ee6f95b56c295 100644 (file)
@@ -2019,7 +2019,7 @@ void cleanup_root(void *arg)
    /* NOTREACHED */
 }
 
-static void
+static void __attribute__((constructor))
 init_global_thread_specific_state ( void )
 {
    int res;