From: Bertram Scharpf Date: 2008-09-02T19:36:05+09:00 Subject: Re: rb_require() causes segfault Hi, Am Dienstag, 02. Sep 2008, 03:42:29 +0900 schrieb Bertram Scharpf: > calling rb_require() with a file name that will not be found, > causes a segmentation fault to be raised: > > ruby: [BUG] Segmentation fault > ruby 1.8.6 (2008-08-11) [i386-freebsd7] > > Abort trap: 6 (core dumped) OK, I start to debug it. The segfault happens in rb_rescue2()/eval.c, line 5501 at a JUMP_TAG() statement. This is when the LoadError exception is being handled, not in the actual rb_require() itself. When I comment in the rb_raise() call below, the segfault won't happen. Would this information help somebody enlighten me what is going on here? Thanks in advance. Bertram Here's my code: ---------------------------------------------------------------- #include VALUE call_require( VALUE name) { if (0) rb_raise( rb_eStandardError, "don't do it"); return rb_require( (char *) name); } VALUE rescue_require( VALUE data, VALUE err) { printf("Error: [[[%s]]]\n", RSTRING(rb_obj_as_string(err))->ptr); return Qnil; } void sure_require( char *name) { rb_rescue( &call_require, (VALUE) name, &rescue_require, Qnil); } int main( int argc, char *argv) { ruby_init(); ruby_init_loadpath(); sure_require( "nonexistent"); return 0; } ---------------------------------------------------------------- -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de