From: ts Date: 2003-02-28T23:39:16+09:00 Subject: Re: I'm stuck >>>>> "F" == Friedrich Dominicus writes: F> ts writes: >> >>>>> "F" == Friedrich Dominicus writes: >> F> int main (void){ F> int i; F> VALUE obj; F> VALUE klass; F> ruby_init(); /* embed Ruby into this program! */ >> >> /* At this step you are playing a dangerous game with the GC */ F> what you you mean which this step ? F> ruby_init? How should I know what else to set up or use? Here a stupid example : int main(void) { char i; VALUE obj; VALUE klass; ruby_init(); obj = rb_str_new2("a string"); /* call some ruby functions which call the GC */ i = RSTRING(obj)->ptr[0]; /* there are many chances than the String referenced by obj was removed by the GC, and you have a segfault when you try to access RSTRING(obj)->ptr[0] */ return 0; } F> Thanks I'll rewrite my stuff. I just wonder how you learned the usage, F> as told before I have searched a lot if messages, but did not found F> something that shows this... You have also rb_load_protect() if you want to load a file and catch the errors rb_load_protect(VALUE path, int wrap, int *state); if wrap is not null, ruby make the load in an anonymous module If ruby has an error, state will be not null. Guy Decoux