From: Shugo Maeda Date: 2001-09-03T16:32:04+09:00 Subject: [ruby-talk:20744] Re: eruby 0.9.6 doesn't work with ruby 1.7.1 Hi, At Sun, 2 Sep 2001 13:44:44 +0200 (MET DST), ts wrote: > Finally I can reproduce the problem with this modification : > > pigeon% diff -u eruby_lib.c~ eruby_lib.c > --- eruby_lib.c~ Mon Aug 6 11:42:47 2001 > +++ eruby_lib.c Sun Sep 2 13:26:02 2001 > @@ -685,6 +685,7 @@ > else { > earg.src = code; > earg.filename = rb_str_new2(filename); > + rb_gc(); > rb_protect(eval_string, (VALUE) &earg, &status); > } > if (state) *state = status; (snip) > compiler and f must be protected against the GC compiler and f are auto variables, so they should be protected against Ruby's conservative GC... but they seem not to be protected on Ruby 1.7. Why? > matz VALUE eruby_load(char *filename, int wrap, int *state) { VALUE compiler; VALUE code; VALUE f; VALUE vfilename = rb_str_new2(filename); compile_arg_t carg; eval_arg_t earg; int status; /* This code protect f against the GC. but why do we need this? rb_gc_register_address(&f); */ if (strcmp(filename, "-") == 0) { f = rb_stdin; } else { f = rb_protect(file_open, (VALUE) filename, &status); if (status) { if (state) *state = status; return Qnil; } } compiler = eruby_compiler_new(); eruby_compiler_set_sourcefile(compiler, vfilename); carg.compiler = compiler; carg.input = f; code = rb_protect(eruby_compile_file, (VALUE) &carg, &status); if (status) { if (state) *state = status; return Qnil; } if (wrap) { rb_eval_string_wrap(STR2CSTR(code), &status); } else { earg.src = code; earg.filename = vfilename; rb_gc(); /* why this break f? */ rb_protect(eval_string, (VALUE) &earg, &status); } if (state) *state = status; if (f != rb_stdin) rb_io_close(f); return code; } Shugo