Return in Fiber dumps core

e$B$3$s$P$s$O!"e(B sheepman e$B$G$9!#e(B

Fiber e$B$N%V%m%C%/$NCf$Ge(B return e$B$r8F$V$He(B segv e$B$7$^$9!#e(B

$ cat f2.rb
Fiber.new do
return
end.yield

$ ruby-1.9 -v f2.rb
ruby 1.9.0 (2007-06-04 patchlevel 0) [i686-linux]
f2.rb:1: – stack frame ------------
0000 (0x40202008): 00000000
0001 (0x4020200c): 00000004
0002 (0x40202010): 00000001
0003 (0x40202014): 00000004
0004 (0x40202018): 402a6350
– control frame ----------
c:0003 p:0019 s:0005 b:0005 l:0x0a14 d:0x0a14 TOP f2.rb:1
c:0002 p:---- s:0003 b:0003 l:000002 d:000002 FINISH :inherited
c:0001 p:---- s:0001 b:-001 l:000000 d:000000 ------

– backtrace of native function call (Use addr2line) –
0x80c1b40
0x80d5119
0x80a08cf
0x4002fe8e
0x400ef908
0x8057bb3
0x8057bf7
0x805ac8d
0x805b009
0x8056f28
0x8059d39
0x805a008
0x80c38e5
0x80bf841
0x80c04d2
0x80c0867
0x80c1ca4
0x805954d
0x8059578
0x80595b3
0x8056df8
0x400dcc1f
0x8056d3d

[BUG] Segmentation fault
ruby 1.9.0 (2007-06-04) [i686-linux]

zsh: abort ruby-1.9 -v f2.rb

(gdb) bt
#0 0x400efc11 in kill () from /lib/i686/libc.so.6
#1 0x4002d341 in pthread_kill () from /lib/i686/libpthread.so.0
#2 0x4002d6bb in raise () from /lib/i686/libpthread.so.0
#3 0x400ef8a4 in raise () from /lib/i686/libc.so.6
#4 0x400f1008 in abort () from /lib/i686/libc.so.6
#5 0x080d5112 in rb_bug (fmt=0x8101eb2 “Segmentation fault”) at
…/ruby/error.c:233
#6 0x080a08cf in sigsegv () at …/ruby/signal.c:533
#7 0x4002fe8e in __pthread_clock_settime () from
/lib/i686/libpthread.so.0
#8 0x400ef908 in killpg () from /lib/i686/libc.so.6
#9 0x08057bb3 in search_method (klass=1073949572, id=3221217820,
klassp=0x0) at eval_method.h:203
#10 0x08057bf7 in rb_get_method_body (klass=135692633, id=5056,
idp=0xbfffe618)
at eval_method.h:230
#11 0x0805ac8d in rb_call (klass=135692633, recv=1076519640, mid=5056,
argc=0, argv=0x0, scope=3)
at …/ruby/eval.c:1380
#12 0x0805b009 in rb_funcall (recv=1076519640, mid=5056, n=0) at
ruby.h:772
#13 0x08056f28 in get_backtrace (info=1076519640) at eval_error.h:54
#14 0x08059d39 in rb_longjmp (tag=6, mesg=1076519640) at
…/ruby/eval.c:679
#15 0x0805a008 in rb_exc_fatal (mesg=1076519640) at …/ruby/eval.c:724
#16 0x080c38e5 in rb_thread_execute_interrupts () at
…/ruby/thread.c:717
#17 0x080bf841 in th_eval (th=0x8133f78, initial=0) at insns.def:2263
#18 0x080c04d2 in th_eval_body (th=0x8133f78) at …/ruby/vm.c:1631
#19 0x080c0867 in rb_thread_eval (th=0x8133f78, iseqval=1076520500) at
…/ruby/vm.c:1837
#20 0x080c1ca4 in yarvcore_eval_iseq (iseq=1076520500) at
…/ruby/yarvcore.c:98
#21 0x0805954d in ruby_exec_internal () at …/ruby/eval.c:212
#22 0x08059578 in ruby_exec () at …/ruby/eval.c:227
#23 0x080595b3 in ruby_run () at …/ruby/eval.c:246
#24 0x08056df8 in th_get_ruby_level_cfp (th=0x8168159, cfp=0x6) at
…/ruby/main.c:47
#25 0x400dcc1f in __libc_start_main () from /lib/i686/libc.so.6

e$B$J$+$@$G$9!#e(B

At Tue, 5 Jun 2007 00:00:38 +0900,
sheepman wrote in [ruby-dev:30888]:

Fiber e$B$N%V%m%C%/$NCf$Ge(B return e$B$r8F$V$He(B segv e$B$7$^$9!#e(B

[ruby-dev:30889]e$B$b860x$OF1$8$@$H;W$$$^$9!#e(B

Index: cont.c

— cont.c (revision 12440)
+++ cont.c (working copy)
@@ -437,5 +437,5 @@ rb_fiber_start(void)

 if (state) {
  • th->thrown_errinfo = th->errinfo;
  • th->thrown_errinfo = th_make_jump_tag_but_local_jump(state,
    th->errinfo);
    th->interrupt_flag = 1;
    }
    Index: eval_intern.h
    ===================================================================
    — eval_intern.h (revision 12440)
    +++ eval_intern.h (working copy)
    @@ -123,5 +123,5 @@ char *strrchr _((const char *, const cha
    }
    else { \
  •  rb_fiber_start(th); \
    
  •  rb_fiber_start(); \
    
    } while (0)

@@ -194,4 +194,6 @@ VALUE rb_f_eval(int argc, VALUE *argv, V
VALUE rb_make_exception _((int argc, VALUE *argv));

+NORETURN(void rb_fiber_start(void));
+
NORETURN(void rb_raise_jump _((VALUE)));
NORETURN(void print_undef _((VALUE, ID)));
@@ -204,4 +206,5 @@ NODE *th_get_cref(rb_thread_t *th, rb_is
NODE *th_cref_push(rb_thread_t *th, VALUE, int);
NODE *th_set_special_cref(rb_thread_t *th, VALUE *lfp, NODE *
cref_stack);
+VALUE th_make_jump_tag_but_local_jump(int state, VALUE val);

static rb_control_frame_t *

e$B!!$5$5$@$G$9!#e(B

Nobuyoshi N. e$B$5$s$O=q$-$^$7$?e(B:

Fiber e$B$N%V%m%C%/$NCf$Ge(B return e$B$r8F$V$He(B segv e$B$7$^$9!#e(B

[ruby-dev:30889]e$B$b860x$OF1$8$@$H;W$$$^$9!#e(B

e$B!!$$$d!"0c$C$?$h$&$G$9!#$J$s$G$+$o$+$i$J$$$1$I!"e(Bth->tag
e$B$,%k!<e(B
e$B%W$7$F$$$^$7$?!#e(Btag->prev == tag
e$B$K$J$C$F$$$^$7$?!#$J$s$G$@$m$&!#e(B

e$B!!JQ99$O!"%F%9%H$H$H$b$K<h$j9~$_$^$7$?!#e(B