Hi,

At Wed, 2 Jun 2004 04:03:37 +0900,
Philipp Kern wrote in [ruby-talk:102037]:
> As soon as you eval something in TOPLEVEL_BINDING Ruby segfaults:
> 
> irb(main):001:0> TOPLEVEL_BINDING
> => #<Binding:0x402b4074>
> 
> irb(main):002:0> eval('puts "Hello!"', TOPLEVEL_BINDING)
> (irb):2: [BUG] Segmentation fault
> ruby 1.9.0 (2004-05-27) [i686-linux-gnu]

I expect it has been fixed.

$ ruby -v -e 'eval(%[puts "Hello!"], TOPLEVEL_BINDING)'
ruby 1.9.0 (2004-05-28) [i686-linux]
Hello!

Apply this patch if you need it immediately.


Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.666 retrieving revision 1.667 diff -U2 -p -d -r1.666 -r1.667 --- eval.c 26 May 2004 05:19:49 -0000 1.666 +++ eval.c 28 May 2004 02:20:34 -0000 1.667 @@ -2932,5 +2932,4 @@ rb_eval(self, n) PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { - ruby_frame->node = node; result = rb_eval(self, node->nd_iter); } @@ -6044,5 +6043,5 @@ eval(self, src, scope, file, line) old_wrapper = ruby_wrapper; ruby_wrapper = data->wrapper; - if (file == 0 || (line == 1 && strcmp(file, "(eval)") == 0)) { + if ((file == 0 || (line == 1 && strcmp(file, "(eval)") == 0)) && data->frame.node) { file = data->frame.node->nd_file; if (!file) file = "__builtin__";
-- Nobu Nakada