[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

segmentation fault at pthread_exit



Hi all,

I ran a simple test case on RHEL-3.0-update1 on ia64 but got
segmentation fault _sometime_.

System info:
-----------------
4 x Itanium2, 1GB DDR
Red Hat Enterprise Linux AS release 3 (Taroon Update 1 Beta)
Linux 2.4.21-6.EL #1 SMP 
	
# gcc -v
Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-	system-zlib --enable-__cxa_atexit
--host=ia64-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-24)
	
#/lib/libc.so.6.1
GNU C Library stable release version 2.3.2, by Roland McGrath et al.
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.2.3 20030502 (Red Hat Linux 3.2.3-23).
Compiled on a Linux 2.4.20 system on 2003-11-07.
Available extensions:
        GNU libio by Per Bothner
        crypt add-on version 2.1 by Michael Glad and others
        linuxthreads-0.10 by Xavier Leroy
        The C stubs add-on version 2.1.2.
        BIND-8.2.3-T5B
        libthread_db work sponsored by Alpha Processor Inc
        NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Thread-local storage support included.
Report bugs using the `glibcbug' script to <bugs gnu org>.
	
Test case:
----------------------
/* test.c */
#include <pthread.h>
#include <stdio.h>

void *a_thread_func()
{
        pthread_exit(0);
        return NULL;
}

int main()
{
        pthread_t new_th;

        printf("---------------\n");
        if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0)
        {
                printf("Error creating thread\n");
                return -1;
        }

        //pthread_join(new_th, NULL);
        printf("Test PASSED\n");
        return 0;
}

Reproduce Steps:
----------------------
1. # gcc -o test test.c -lpthread
2. # ldd ./test
        libpthread.so.0 => /lib/tls/libpthread.so.0 (0x2000000000040000)
        libc.so.6.1 => /lib/tls/libc.so.6.1 (0x2000000000070000)
        /lib/ld-linux-ia64.so.2 => /lib/ld-linux-ia64.so.2
(0x2000000000000000) 
(the test program links to NPTL, /lib/tls/libpthread.so.0 ->
libpthread-0.60.so )

3. # for ((i=0; i<1000; i++)) ; do ./test; done > out 2>&1
4. In one run, there are 31 "segmentation fault" among 1000 runs.
........
---------------
Test PASSED
---------------
Test PASSED
Segmentation fault
---------------
Test PASSED
--------------- 
............

------------------------------------------------------------------------
----------
When I add a pthread_join() as above, there is _no_ segmentation fault
for 1000 runs.
It seems when the two threads exit at the same time, the segmentation
will happen.
Also in my trying on ia32 on RHEL-3.0 update1, this test case also works
fine.

I turn to add some debug info to a libc-20040201 source and link against
it, (same gcc, but with kernel linux-2.6.1-mm2)
here are some output: 

---------------
[test] after thread_setmem()
[test] HAVE_FORCED_UNWIND
[test] THREAD_SETMEM, exc.exception_class
[test] THREAD_SETMEM, exc.exception_cleanup
[test] __buildin_expect (libgcc_s_getcfa)
[test] before libc_dlopen() libgcc_s.so.1
Test PASSED
Segmentation fault
---------------
It seems the segmentation fault happened when libc try to load
libgcc_s.so.1 (or maybe when call into it).

When there is pthread_join(), the output looks like:
---------------
[test] after thread_setmem()
[test] HAVE_FORCED_UNWIND
[test] THREAD_SETMEM, exc.exception_class
[test] THREAD_SETMEM, exc.exception_cleanup
[test] __buildin_expect (libgcc_s_getcfa)
[test] before libc_dlopen() libgcc_s.so.1
[test] after libc_dlopen() libgcc_s.so.1
[test] before getting the func ptr
[test] exit pthread_cancel_init
[test] bofore libgcc_s_forceunwind()
Test PASSED
---------------

BTW, in many systems, e.g, RHEL-3.0-udpate1 (ia32 and ia64), RH9, when I
try:

# /lib/libgcc_s.so.1

I always get segmentation fault. I am not sure whether this should be
normal or not.


Did I miss anything?  Hoping for your comments.

-adam
------------------------------------------------
Message above is personal view, not my employer's.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]