SIGSEGV: exceptions with thread specific data

Pavel Krauz kra@cri.cz
Wed Mar 10 10:11:00 GMT 1999


I would like to report a problem (possible bug) in exception
code, but it could also be a problem in glibc-2.0.7 or linuxthreads.

The problem is that when working with threads with threadspecific data
and mixing it little bit with exception handling the program SIGSEGV
in exit() function (when trying to deallocate something).

I am running RedHat-5.2 with egcs-1.0.3 and glibc-2.0.7,
linuxthreads-0.7


Please let me know if this problem exists on glibc-2.1.X or egcs-1.1.X
or if it is a bug of egcs or glibc or linuxthreads

Please reply personally as I don't get this mailing list

Thanks in advance
Pavel Krauz <kra@cri.cz>



Here is the bug reproduction:

Makefile:
-----------------------------------------

LDFLAGS=
LDLIB=-lpthread -lstdc++
CFLAGS=-D_REENTRANT
CXX=egcs

all: t


.cc.o:
        $(CXX) ${CFLAGS} -c -o $@ $<

t: t.o
        $(CXX) -o $@ $< -L.. $(LDLIB)

-----------------------------------------
t.cc
-----------------------------------------
#include <pthread.h>
#include <stdio.h>

pthread_key_t key;

void *main_thr(void *)
{
        int i;

        // here linuxthreads allocate through calloc thread specific
data
        pthread_setspecific(key, "asd");// try move after catch

        try {
                throw 1;                // try disable
        }
        catch (int i) {
                printf("cought\n");
        }
        pthread_setspecific(key, NULL);
}

void main()
{
        pthread_t t_id;

        pthread_key_create(&key, NULL);

        pthread_create(&t_id, NULL, main_thr, NULL);
        pthread_join(t_id, NULL);
        pthread_key_delete(key);        // try disable

        exit(0);
}





More information about the Gcc-bugs mailing list