From: Brian Candler Date: 2003-07-23T22:20:09+09:00 Subject: Re: Embedding problem - SEGV On Wed, Jul 23, 2003 at 08:57:55PM +0900, ts wrote: > >>>>> "B" == Brian Candler writes: > > B> I have grepped the source and found "ruby_init_loadpath" to set $:, but is > B> there something else I need to call to fix the SEGV problem? > > Use rb_protect() to run your code. > > Something like > > ruby_init(); > ruby_init_loadpath(); > result = rb_protect(some_functions, some_args, &status); > > some_functions() will call rb_require(), ... That's pretty icky. I'm happy for Ruby to generate an exception report and exit; I just don't want it to dump core. Here's the sort of thing I want to do when processing a config file: static VALUE obj; static void process_line(char *cmd, char *arg) { if (!strcmp(cmd, "loadLibrary")) rb_require(arg); else if (!strcmp(cmd, "loadObject")) { VALUE klass = rb_const_get(rb_cObject, rb_intern(arg)); obj = rb_funcall(klass, rb_intern("new"), 0); } /* ... etc */ } Do I really have to write each section as a separate C function, and call it under rb_protect? Regards, Brian.