Segv when reentering into Fiber with callcc

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

e$B=*N;$7$?e(B Fiber e$B$Ke(B callcc e$B$G:FF~$9$k$He(B segv
e$B$7$^$9!#e(B

$ cat f.rb
Fiber.new do
if callcc{|c| $k = c }
p 1
else
p 3
end
end.pass
p 2
$k.call

$ ruby-1.9 -v f.rb
ruby 1.9.0 (2007-06-01 patchlevel 0) [i686-linux]
1
2
3
SEGV recieved in SEGV handler

e$B0J2<$O%P%C%/%H%l!<%9$G$9!#e(B

(gdb) bt
#0 0x000007e0 in ?? ()
#1 0x080c042e in th_eval_body (th=0x8133eb0) at …/ruby/vm.c:1631
#2 0x080bb901 in invoke_block (th=0x8133eb0, block=0x8171d30,
self=1076562140, argc=0,
argv=0x8172010, magic=-83886223) at …/ruby/vm.c:799
#3 0x080bba8d in th_invoke_proc (th=0x8133eb0, proc=0x8171d30,
self=1076562140, argc=0,
argv=0x8172010) at …/ruby/vm.c:839
#4 0x080c644a in rb_fiber_start () at …/ruby/cont.c:433
#5 0x0805953c in ruby_exec_internal () at …/ruby/eval.c:212
#6 0x08059554 in ruby_exec () at …/ruby/eval.c:227
#7 0x0805958f in ruby_run () at …/ruby/eval.c:246
#8 0x08056dd4 in th_get_ruby_level_cfp (th=0x7e0, cfp=0x0) at
…/ruby/main.c:47
#9 0x400dcc1f in __libc_start_main () from /lib/i686/libc.so.6

[email protected]$G$9!#e(B

sheepman e$B$5$s$O=q$-$^$7$?e(B:

e$B=*N;$7$?e(B Fiber e$B$Ke(B callcc e$B$G:FF~$9$k$He(B segv e$B$7$^$9!#e(B

e$B!!e(B[ruby-dev:30886][email protected]$H;W$&$s$G$9$,!"$I$&$$$&5sF0$,@5$7$$e(B
e$B$N$+$h$/$o$+$i$J$+$C$?$N$G!"$H$j$"$($:$=$&$$$&$3$H$O6X;$9$k$he(B
e$B$&$K$7$F$
$^$7$?!#e(B

e$B1sF#$H?=$7$^$9!#e(B

e$B=*N;$7$?e(B Fiber e$B$Ke(B callcc e$B$G:FF~$9$k$He(B segv e$B$7$^$9!#e(B
e$B!!e(B[ruby-dev:30886][email protected]$H;W$&$s$G$9$,!"$I$&$$$&5sF0$,@5$7$$e(B
e$B$N$+$h$/$o$+$i$J$+$C$?$N$G!"$H$j$"$($:$=$&$$$&$3$H$O6X;$9$k$he(B
e$B$&$K$7$F$
$^$7$?!#e(B

[ruby-dev:30886] e$B$O=EJ#$G<:Ni$7$^$7$?!#e(B

e$B>e5-$NNc$OMn$A$J$/$J$C$?$N$r3NG’$7$^$7$?$,!"e(B
callcc e$B$G$O;$s$G$J$$e(B fiber e$B$KHt$S9~$$3$H$b$G$-$k$H;W$$$^$9!#e(B

$ ./ruby -e ’
c = nil
f1 = f2 = nil
f1 = Fiber.new do
callcc do |c2|
c = c2
f2.yield
end
end
f2 = Fiber.new do
c.call
end
f1.yield

*** glibc detected *** double free or corruption (!prev): 0x08190900 ***
e$B%"%!<%H$7$^$7$?e(B

[email protected]$G$9!#e(B

Yusuke ENDOH e$B$5$s$O=q$-$^$7$?e(B:

e$B>e5-$NNc$OMn$A$J$/$J$C$?$N$r3NG’$7$^$7$?$,!"e(B
callcc e$B$G$O;$s$G$J$$e(B fiber e$B$KHt$S9~$$3$H$b$G$-$k$H;W$$$^$9!#e(B

e$B!!$3$N0UL#$,$h$/$o$+$i$J$+$C$?$s$G$9$,!"$H$j$"$($:%P%0$rD>$7$Fe(B
e$BD:$$$?Nc$rF0$/$h$&$K$7$^$7$?!#e(B

e$B1sF#$G$9!#e(B

e$B>e5-$NNc$OMn$A$J$/$J$C$?$N$r3NG’$7$^$7$?$,!"e(B
e$B$^$?JL$NNc$r8+$D$1$^$7$?!#e(B

$ ./ruby -e ‘callcc {|c| Fiber.new { c.call }.yield }’
: – stack frame ------------
– control frame ----------
c:0004 p:---- s:-33960828 b:-001 l: (nil) d: (nil) ------
c:0003 p:---- s:-33960828 b:-001 l: (nil) d: (nil) ------
c:0002 p:---- s:-33960828 b:-001 l: (nil) d: (nil) ------
c:0001 p:---- s:-33960828 b:-001 l: (nil) d: (nil) ------

– backtrace of native function call (Use addr2line) –
0x80d94ea
0x80f23b0
0x80b2229
0xffffe420
0x80deec7
0x80d111e
0x80d5a19
0x80d74f3
0x80d7a52
0x80d7e17
0x80df125
0x8059179
0x8059196
0x805d691
0x8056d3f
0xb7d6eea8
0x8056c71

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

e$B%"%!<%H$7$^$7$?e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30913] Re: segv when reentering into Fiber
with callcc”
on Thu, 7 Jun 2007 12:50:20 +0900, SASADA Koichi [email protected]
writes:

|Yusuke ENDOH e$B$5$s$O=q$-$^$7$?e(B:
|> e$B>e5-$NNc$OMn$A$J$/$J$C$?$N$r3NG’$7$^$7$?$,!“e(B
|> e$B$^$?JL$NNc$r8+$D$1$^$7$?!#e(B
|>
|> $ ./ruby -e ‘callcc {|c| Fiber.new { c.call }.yield }’
|
|e$B!!D>$7$^$7$?!#e(B
|
|e$B!!$7$+$7!”[email protected]$1%P%0$,=P$F$/$k$N$O$D$i$$$N$G!"$d$C$Q$je(B
|callcc e$B$d$a$h$&$+$J!#e(B

e$B$=$N5$;}$A$O$o$+$j$^$9!#e(Bakre$B$5$s$K%A%’%C%/$5$l$?;~$H$+!"FC$K!#e(B

In article [email protected],
Yukihiro M. [email protected] writes:

|e$B!!$7$+$7!"[email protected]$1%P%0$,=P$F$/$k$N$O$D$i$$$N$G!"$d$C$Q$je(B
|callcc e$B$d$a$h$&$+$J!#e(B

e$B$=$N5$;}$A$O$o$+$j$^$9!#e(Bakre$B$5$s$K%A%’%C%/$5$l$?;~$H$+!"FC$K!#e(B

e$BL5$/$;$P$$$$$8$c$J$$$G$9$+!#e(B

[email protected]$G$9!#e(B

Yusuke ENDOH e$B$5$s$O=q$-$^$7$?e(B:

e$B>e5-$NNc$OMn$A$J$/$J$C$?$N$r3NG’$7$^$7$?$,!"e(B
e$B$^$?JL$NNc$r8+$D$1$^$7$?!#e(B

$ ./ruby -e ‘callcc {|c| Fiber.new { c.call }.yield }’

e$B!!D>$7$^$7$?!#e(B

e$B!!$7$+$7!"[email protected]$1%P%0$,=P$F$/$k$N$O$D$i$$$N$G!"$d$C$Q$je(B
callcc e$B$d$a$h$&$+$J!#e(B

call/cc e$BJY6/Cf$N=i?4<T:XF#$G$9!#e(B
;; ((call/cc call/cc) (call/cc call/cc)) e$B$H$+e(B

e$B$"$/$^$GCf?H$NJ,$+$C$F$J$$?M4V$N0U8+$G$9$,!"e(B

On Thu, 7 Jun 2007 12:50:20 +0900
SASADA Koichi [email protected] wrote:

e$B!!$d$C$Q$je(B
callcc e$B$d$a$h$&$+$J!#e(B

+1e$B!#e(B

e$B:XF#$G$9!#O"Ej:Q$_$^$;$s!#%l%]!<%HEj$2$kA0$K$H$j$"$($:!#e(B

e$B$5$i$KDI$$7b$A$r$+$1$k$H!"e(Bakre$B$5$s$,e(B2004e$BG/e(B9e$B7n!AG/Kv$K$+$1$FEj$2$i$l$?e(B
callcce$B$K$^$D$o$ke(BSEGVe$B%l%]!<%H$N$$$/$D$+$,!"8=>u$N<BAu$G$bF1MM$KMn$A$ke(B
e$B;v$r<j85$G3NG’$7$F$$$^$9!#e(B
(e$BNc$($Pe(B[ruby-dev:24291]e$B$re(B s/send/funcall/ e$B$7$?$b$Ne(B)

e$B$^[email protected]$9$Y$F3NG’$O$7$F$$$^$;$s$N$G!"$H$j$"$($::#F|$"$?$j!"$^$H$a$FJs9p$re(B
e$BEj$2$h$&$+$H9M$($F$$$^$7$?!#$3$l$i$N>l9g$O!“2r7hJ}K!$b$”$kDxEY$O$^$Me(B
e$B$i$l$k$N$+$b$7$l$^$;$s$,!"<+J,$O$h$/J,$+$j$^$;$s!#e(B

(e$B$&$l$7$5e(B / e$BJ]<i%3%9%He(B) e$B$NH=CG$K?T$-$k$H;W$$$^$9!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30915] Re: segv when reentering into Fiber
with callcc”
on Thu, 7 Jun 2007 14:40:44 +0900, Tanaka A. [email protected]
writes:

|> |callcc e$B$d$a$h$&$+$J!#e(B
|>
|> e$B$=$N5$;}$A$O$o$+$j$^$9!#e(Bakre$B$5$s$K%A%’%C%/$5$l$?;~$H$+!"FC$K!#e(B
|
|e$BL5$/$;$P$$$$$8$c$J$$$G$9$+!#e(B

e$B!Ve(Bcallcce$B$,$J$$$>!W$H$$$&@<$H!Ve(Bcallcce$B$G$3$s$J%P%0$,!W$H$$$&@<e(B
e$B$N$I$C$A$,$&$k$5$$$H;W$&$+$G$9$h$M!#;d$H$7$F$O$"$k$b$N$r:o$ke(B
e$B$N$OG&$S$J$$e(B(e$B%P%0$O$N$s$S$j$D$V$7$F$$$1$P$=$N$&$A8:$ke(B)e$B$H;W$Ce(B
e$B$F$k$N$G$9$,!":{ED$/$s$N4uK>$rJ9$/5$;}$A$O$"$j$^$9!#e(B

e$B1sF#$G$9!#e(B

e$BA0$NNc$GMn$A$J$/$J$k$3$H$r3NG’$7$^$7$?$,!"e(B
e$B$^$?e(B callcc e$B$He(B Fiber
e$B$,$i$_$GJL$NNc$r8+$D$1$F$7$^$$$^$7$?!#e(B

$ ./ruby -e ’
c = callcc {|c| c }
Fiber.new { c.call }.yield

-e:3:in `’: unhandled exception
SEGV recieved in SEGV handler

e$BF1$8LdBj$+$I$&$+$O$o$+$j$^$;$s$,!“e(B
e$B0J2<$Oe(B Ctrl-C e$B$G;_$a$?8e$Ke(B segv e$B$r<u$1$^$9!#e(B
e$B$”$H!"%(%i!<$N9THV9f$b$J$s$+JQ$G$9!#e(B

$ ./ruby -e ’
f = nil
callcc {|c| f = Fiber.new { c.call } }
f.yield

-e:15084:in `’: Interrupt
SEGV recieved in SEGV handler

e$B!Ve(Bcallcce$B$,$J$$$>!W$H$$$&@<$H!Ve(Bcallcce$B$G$3$s$J%P%0$,!W$H$$$&@<e(B
e$B$N$I$C$A$,$&$k$5$$$H;W$&$+$G$9$h$M!#e(B

e$B8D?ME*$K$Oe(B callcc e$B$,$J$$$H<d$7$$GI$J$N$G%P%0=P$7$7$F$$$^$9!#e(B

[email protected]$G$9!#e(B

At Thu, 7 Jun 2007 19:44:26 +0900,
Yusuke ENDOH wrote in [ruby-dev:30923]:

e$BA0$NNc$GMn$A$J$/$J$k$3$H$r3NG’$7$^$7$?$,!"e(B
e$B$^$?e(B callcc e$B$He(B Fiber e$B$,$i$_$GJL$NNc$r8+$D$1$F$7$^$$$^$7$?!#e(B

$ ./ruby -e ’
c = callcc {|c| c }
Fiber.new { c.call }.yield

-e:3:in `’: unhandled exception
SEGV recieved in SEGV handler

e$B%9%?%C%/$NJ]B8MQNN0h$NFs=E2rJ|$N$h$&$G$9$M!#e(B

e$BF1$8LdBj$+$I$&$+$O$o$+$j$^$;$s$,!“e(B
e$B0J2<$Oe(B Ctrl-C e$B$G;_$a$?8e$Ke(B segv e$B$r<u$1$^$9!#e(B
e$B$”$H!"%(%i!<$N9THV9f$b$J$s$+JQ$G$9!#e(B

e$B9THV9f$O<j85$N$G$O$A$c$s$H=P$F$k$s$G$9$,!"[email protected][email protected]$C$?$+$J!D!#e(B

Index: cont.c

— cont.c (revision 12471)
+++ cont.c (working copy)
@@ -70,5 +70,9 @@ cont_free(void *ptr)
if (ptr) {
rb_context_t *cont = ptr;

  • FREE_UNLESS_NULL(cont->saved_thread.stack);
  • rb_thread_t *th = DATA_PTR(cont->saved_thread.self);
  • if (cont->saved_thread.stack != th->stack) {
  •  FREE_UNLESS_NULL(cont->saved_thread.stack);
    
  • }
    FREE_UNLESS_NULL(cont->machine_stack);
    FREE_UNLESS_NULL(cont->vm_stack);

e$B$3$s$K$A$O!"e(Bsheepman e$B$G$9!#e(B

On Fri, 8 Jun 2007 02:53:02 +0900
Nobuyoshi N. [email protected] wrote:

e$BF1$8LdBj$+$I$&$+$O$o$+$j$^$;$s$,!“e(B
e$B0J2<$Oe(B Ctrl-C e$B$G;_$a$?8e$Ke(B segv e$B$r<u$1$^$9!#e(B
e$B$”$H!"%(%i!<$N9THV9f$b$J$s$+JQ$G$9!#e(B

e$B9THV9f$O<j85$N$G$O$A$c$s$H=P$F$k$s$G$9$,!"[email protected][email protected]$C$?$+$J!D!#e(B

[ruby-dev:30833] e$B$+$J!#e(B

e$B1sF#$G$9!#e(B

[ruby-dev:30926]
e$B$,%3%_%C%H$5$l$J$$$N$OK:$l$i$l$F$$$k$N$G$7$g$&$+!#e(B
e$B$H$j$"$($:$3$N%Q%C%A$Ge(B segv
e$B$,5/$-$J$/$J$k$3$H$O3NG’$7$F$$$^$9!#e(B

07/06/08 e$B$Ke(B Nobuyoshi N.[email protected]
e$B$5$s$O=q$-$^$7$?e(B:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs