[Gc] GC 6.2 on Suse

Alec Orr Alec.Orr at wbemsolutions.com
Wed May 5 11:15:07 PDT 2004


Hello again folks,

We seem to be having a problem with GC 6.2 on SuSe 9.0 (uname -a: Linux 
starfury 2.4.21-202-athlon #1 Fri Apr 2 21:22:14 UTC 2004 i686 athlon 
i386 GNU/Linux). We have been using GC 6.2 for a while on Red Hat 8.0 
for a while with little trouble, we recently tried to bring our 
application over to SuSe but when we run our program we get a 
segmentation fault in the GC_init_thread_local function (it's being 
passed a NULL parameter). We took the example application 
(http://www.hpl.hp.com/personal/Hans_Boehm/gc/simple_example.html) and 
tried that and it worked fine, but our application is multithreaded 
(well the primary thread is basically paused and the secondary thread is 
listening on a socket). So I made a small change to the sample app (see 
below) and I get the same segmentation fault. Here is the gdb backtrace:

#0  GC_init_thread_local (p=0x0) at pthread_support.c:215
#1  0x40034a5f in GC_init_parallel () at pthread_support.c:947
#2  0x400355c0 in GC_pthread_create (new_thread=0xbffff4cc, attr=0xbffff4d0,
    start_routine=0x1, arg=0x1) at pthread_support.c:1233
#3  0x0804871b in main ()


it appears that the GC_lookup_thread called on line 947 of 
pthread_support.c returns a NULL, which in turn causes 
GC_init_thread_local to segv.

Has anyone else run into this problem, or have any thoughts on what 
maybe going on?

Thank You.

We are using gcc version 3.3.1 (SuSE Linux)

Modified example Program (compile options cc -L/var/tmp/gc/lib -lgc -ldl 
-I /var/tmp/gc/include -D__REENTRANT -DGC_THREADS gctest.c ):
#include "gc.h"
#include <pthread.h>
#include <assert.h>
#include <stdio.h>

void* start(void* data)
{
    return NULL;
}

int main(int argc, char** argv) {
    pthread_attr_t thrdData;
    pthread_t thrd;
    int i;

    GC_INIT();

    pthread_attr_init(&thrdData);
    pthread_attr_setdetachstate(&thrdData, PTHREAD_CREATE_DETACHED);
    /* Commenting the next line out lets program run normally */
    pthread_create(&thrd, &thrdData, start, NULL);


    for (i = 0; i < 10000000; ++i)
    {
    int **p = (int **) GC_MALLOC(sizeof(int *));
    int *q = (int *) GC_MALLOC_ATOMIC(sizeof(int));
    assert(*p == 0);
    *p = (int *) GC_REALLOC(q, 2 * sizeof(int));
    if (i % 100000 == 0)
        printf("Heap size = %d\n", GC_get_heap_size());
    }
    return 0;
}







More information about the Gc mailing list