Re: [Gc] child process goes to crash when the program invokes gtk_init
<[email protected]> Thu, 6 Aug 2015 01:00:14 +0000
| Newsgroups | gmane.comp.programming.garbage-collection.boehmgc |
|---|---|
| Message-ID | <[email protected]> |
Dear Mr. Maidanski and Mr. Matheussen,
Thanks a lot for your response. I'm sorry that I forgot to call GC_INIT at very beginning of the program.
I inserted them into and tested again the next program:
#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;
GC_set_handle_fork(1);
GC_INIT();
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);
}
The result becomes perfect!
$ ./a.exe
adress:0x600060fe0 activesize:64
adress:0x600060fe0 activesize:64
This is a test string.
I greatly appriciate your helps!
Sincerely yours,
Yoichi Niitsu
From: Ivan Maidanski [mailto:[email protected]]
Sent: Thursday, August 06, 2015 6:55 AM
To: [email protected]
Cc: [email protected]; niitsu yoichi(新津 陽一郎 ○MSジ□MS設○AI設)
Subject: Re[2]: [Gc] child process goes to crash when the program invokes gtk_init
Hi,
And call GC_set_handle_fork(1) before GC_INIT().
I assume you use bdwgc master
Среда, 5 августа 2015, 18:11 +02:00 от Kjetil Matheussen <[email protected]>:
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.
Hi,
I've used gtk with boehm-gc in a quite large program before without problems, but not in cygwin, only mingw/osx/linux.
And I didn't fork either. I don't know how forking works in cygwin (think I remember reading something about fork
being impossible to emulate in Windows, but maybe that is not true anymore), and I also don't know if there
is anything (in general) to look out for when forking in a bdwgc program.
But maybe your program works if you just call GC_INIT() right after main?
_______________________________________________
bdwgc mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/bdwgc
_______________________________________________
bdwgc mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/bdwgc