[Gc] child process goes to crash when the program invokes gtk_init

<[email protected]> Wed, 5 Aug 2015 05:35:55 +0000
Newsgroups gmane.comp.programming.garbage-collection.boehmgc
Message-ID <[email protected]>
I wrote a tiny test program as seen in the following:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <gtk/gtk.h>
#include <sys/wait.h>

#define GC_DEBUG
#include <gc.h>

char *copy (const char *str)
{
    char *p = NULL;
    if (!str) return NULL;
    if ((p = GC_MALLOC_ATOMIC(strlen(str) + 1)))
        (void) strcpy(p, str);
    return(p);
}

int main(int argc, char** argv)
{
    pid_t pid;
    int status;
    char *teststr = "This is a test string.";
    char *c1, *c2;


    c1 = copy(teststr);
    printf ("adress:%p activesize:%d\n", c1, (int)GC_size(c1));

    gtk_init(&argc, &argv);

    pid = fork();
    if (pid == 0) {
              c2 = copy ("another test str");

              printf ("adress:%p activesize:%d\n", c1, (int)GC_size(c1));
              printf ("%s\n", c1);

              _exit(0);
    }
    waitpid (pid, &status, 0);
    if (WIFSIGNALED(status)){
              fprintf(stderr, "child signal %d\n", WTERMSIG(status));
    }
    return (0);
}

This program is compiled at Cygwin(64, version 2.2.0) environment with gcc4.9.3. My Cygwin(64) environment is installed to windowns7. The CPU is Intel Core i7-4770 @ 3.4GHz.

However, this program causes SEGV in the child process.
$ ./a.exe
adress:0x600060fe0 activesize:64
child signal 11                  <-- this means child process ended with SIGSEGV.

I confirmed SIGSEGV is raised at
              c2 = copy ("another test str");
that invokes GC_MALLOC_ATOMIC.
But, if gtk_init() is commented out, or if GC_DEBUG is not defined, this program seems to be ended successfully.
$ ./a.exe
adress:0x600060fe0 activesize:32
adress:0x600060fe0 activesize:32   <-- output from child process
This is a test string.               <-- output from child process

gtk is gtk+-2.24.28.
I have fears in using boehm-gc together with gtk+-2.0. Does anyone give me comments/advices ?
Thanks in advance.
Yoichi Niitsu

_______________________________________________
bdwgc mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/bdwgc