[Bug:1.9] 1+1+1+...+1 dumps core


#1

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

e$B0J2<$Ge(B SEGV e$B$7$^$9!#e(B

$ ./ruby -e ‘eval(“1+” * 100000 + “1”)’
e$B%;%0%a%s%F!<%7%g%s0cH?$G$9e(B

iseq_compile_each e$B$N:F5"$G%9%?%C%/%*!<%P!<%U%m!<$9$k$?$a$G$9!#e(B
e$B:F5"?t$N%A%’%C%/$rF~$l$l$PNc30$K$G$-$k$H;W$$$^$9$,!"$3$s$Je(B
e$B%1!<%9$N$?$a$K%3%s%Q%$%k$rCY$/$9$k$N$O$b$C$?$$$J$$5$$b$7$^$9!#e(B
e$B$I$s$J$b$N$G$7$g$&!#e(BWontFix e$B9T$-!)e(B

e$B$^$?!"e(BMVM e$BHG$@$He(B SystemStackError
e$B$H$7$F8!CN$G$-$k$i$7$$$G$9!#e(B

e$B$A$J$_$K!"%Q!<%5$NJ}$G%9%?%C%/%*!<%P!<%U%m!<$9$k>l9g$ONc30$Ke(B
e$B$J$j$^$9e(B (bison e$B$K0MB8$9$k$+$b$7$l$^$;$s$,e(B) e$B!#e(B

$ ./ruby -e ‘eval(“1+(” * 100000 + “1” + “)” * 100000)’
-e:1:in eval': (eval):1: memory exhausted (SyntaxError) ...+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1... ... ^ from -e:1:in


#2

e$B$O$8$a$^$7$F!"$h$7$*$+$H?=$7$^$9!#e(B

e$B2<5-$N%P%0$J$s$G$9$,!"%9%?%C%/%*!<%P!<%U%m!<$Ge(BSIGSEGVe$B$N>l9ge(B
e$B%j%=!<%9$r;H$$$-$C$F$7$^$&$N$G!"%7%0%J%k%O%s%I%i$,F0$/%j%=!<%9e(B
e$B$9$i$J$/$J$C$F$7$^$C$FMn$k$N$G$O$J$$$+$H;W$$$^$9!#e(B

e$BBP=hK!$Oe(BBINARY
HACKSe$B$J$I$K:$C$F$$$ke(Bsigaltstack(2)e$B$H$$$&BeBXe(B
e$B%9%?%C%/$rMQ0U$7$F$"$2$l$PBP=h$G$-$k$N$G$O$J$$$+$H;W$$$^$9!#e(B

e$B$$$:$l$K$;$h!“Mn$k$3$H$K$O$+$o$j$J$$$s$G$9$,!”$I$3$GMn$A$Fe(B
e$B$$$k$+$,$o$+$kDxEY$N$3$H$O$"$k$+$H!#e(B

e$B2<5-$Oe(Bsigaltstack(2)e$B$r;H$C$F<BAu$7$?Nc$G$9!#e(B

$ ./ruby -e ‘p eval(“1+” * 14154 + “1”)’
-e:1: [BUG] Segmentation fault
ruby 1.9.0 (2008-11-01 revision 20086) [i686-linux]

– control frame ----------
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC :eval
c:0003 p:0018 s:0007 b:0006 l:000005 d:000005 TOP -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH :inherited
c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP :17

-e:1:in eval': stack level too deep (SystemStackError) from -e:1:in

e$B$I$N$h$&$KBP=h$7$?$+$OF|5-$K5-$7$^$7$?$N$G!"$4>PMw$/$@$5$$!#e(B
http://d.hatena.ne.jp/hyoshiok/20081116

rubye$B$N$*:nK!$rA4A3$o$+$C$F$$$J$$$N$G!“JQ$J%3!<%I$K$J$C$F$$$ke(B
e$B$H$O;W$$$^$9$,!”%3%a%s%H$$$?$@$1$k$H$&$l$7$$$G$9!#e(B

e$B$he(B

Hiro Y.
Miracle Linux Corporation
http://blog.miraclelinux.com/yume/
http://d.hatena.ne.jp/hyoshiok/

From: “Yusuke ENDOH” removed_email_address@domain.invalid
Subject: [ruby-dev:37007] [Bug:1.9] 1+1+1+…+1 dumps core
Date: Sat, 1 Nov 2008 00:07:42 +0900
Message-ID:
removed_email_address@domain.invalid


#3

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

2008/11/17 0:04 Hiro Y. removed_email_address@domain.invalid:

e$B$$$k$+$,$o$+$kDxEY$N$3$H$O$"$k$+$H!#e(B
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH :inherited
c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP :17

-e:1:in eval': stack level too deep (SystemStackError) from -e:1:in

e$B$I$N$h$&$KBP=h$7$?$+$OF|5-$K5-$7$^$7$?$N$G!"$4>PMw$/$@$5$$!#e(B
http://d.hatena.ne.jp/hyoshiok/20081116

rubye$B$N$*:nK!$rA4A3$o$+$C$F$$$J$$$N$G!“JQ$J%3!<%I$K$J$C$F$$$ke(B
e$B$H$O;W$$$^$9$,!”%3%a%s%H$$$?$@$1$k$H$&$l$7$$$G$9!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#LLGr$$$G$9$M!#e(B

sigaltstack(2) e$B$C$F$I$N$/$i$$%]!<%?%V%k$J$s$G$7$g$&$+!#e(B
Debian e$B$Ne(B man e$B$K$h$k$He(B CONFORMING TO SUSv2, SVr4,
POSIX.1-2001.
e$B$i$7$$$G$9$,!"e(Bwindows e$B$H$+$I$&$J$s$G$7$g$&!#e(B

e$B$=$NJU$,Bg>fIW$=$&$J$i!"!V<h$j9~$`!W$K0lI<$G$9!#e(B


#4

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:37129] Re: [Bug:1.9] 1+1+1+…+1 dumps core”
on Nov.20,2008 02:54:16, removed_email_address@domain.invalid wrote:

sigaltstack(2) e$B$C$F$I$N$/$i$$%]!<%?%V%k$J$s$G$7$g$&$+!#e(B
Debian e$B$Ne(B man e$B$K$h$k$He(B CONFORMING TO SUSv2, SVr4, POSIX.1-2001.
e$B$i$7$$$G$9$,!"e(Bwindows e$B$H$+$I$&$J$s$G$7$g$&!#e(B

Windowse$B$K$"$k$o$-$c$J$$$s$G$9$,!"$^!“e(Bconfiguree$B$GD4$Y$F$”$l$Pe(B
e$B;H$&!"$G$$$$$s$8$c$J$$$G$7$g$&$+!#e(B

e$B$=$l$G$O!#e(B


#5

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

U.Nakamura e$B$5$s$O=q$-$^$7$?e(B:

Windowse$B$K$"$k$o$-$c$J$$$s$G$9$,!"$^!“e(Bconfiguree$B$GD4$Y$F$”$l$Pe(B
e$B;H$&!"$G$$$$$s$8$c$J$$$G$7$g$&$+!#e(B

Windowse$B$GBeBX%9%?%C%/$r;H$($J$$$N$+$H;W$C$FD4$Y$?$i$3$s$J$N$,8+$D$+$j$^e(B
e$B$7$?!#e(B
http://www.nminoru.jp/~nminoru/programming/stackoverflow_handling.html#winnt

e$B$b$7$+$7$Fe(Bcall_cfunce$B$G9=B$2=Nc30$rJa$^$($Fe(BSystemStackErrore$B$KJQ49$7$?$j$Ge(B
e$B$-$^$9e(B?

SEGVe$B%7%0%J%k$@$H$-$D$$$G$9$1$I!“e(BSystemStackErrore$B$rEj$2$kM>M5$,$”$l$P$=$le(B
e$B$K1[$7$?$3$H$O$J$$$G$9$h$M!#e(B


#6

On Fri, 21 Nov 2008 15:12:37 +0900
In article removed_email_address@domain.invalid
[[ruby-dev:37133] Re: [Bug:1.9] 1+1+1+…+1 dumps core]
“U.Nakamura” removed_email_address@domain.invalid wrote:

e$B$7$+$7$3$lBeBX%9%?%C%/NN0h$J$N$+$J!#C1$K:#$V$C2u$7$?%9%?%C%/e(B
e$BNN0h$r$J$+$C$?$3$H$K$7$Fe(B__trye$B!Ae(B__excepte$B@a$N?<$5$K$^$G4,$-La$5e(B
e$B$l$F$k$5$l$F$k$@$1$N$h$&$J5$$,e(B…

SEHe$B$Oe(BCPUe$B$,%H%i%C%W$7$?Nc30$rDLCN$9$k;EAH$_$J$N$G!"e(BSTATUS_STACK_OVERFLOW
e$B$,H/@8$7$F$b%9%?%C%/$O!J$^$@!K$V$C2u$l$F$$$^$;$s!#e(B

__except( … )
e$B$N3g8LFb$r<B9TCf$O!"85$N%9%?%C%/$NB3$-!JBeBX%9%?%C%/!K$re(B
e$B;H$C$F$$$^$9!#$=$&$8$c$J$$$He(B EXCEPTION_CONTINUE_EXECUTION
e$B$G:F<B9T$G$-$Je(B
e$B$$$+$i!#e(B

EXCEPTION_EXECUTE_HANDLER e$B$rJV$9$H!"$=$3$+$ie(B __finally
e$B$r<B9T$7$D$D%9%?%Ce(B
e$B%/$r4,$-La$7$^$9!#e(B

e$B$?$@!"$3$3$Ge(B SystemStackError
e$B$r@8@.$7$F<B9T$r7QB3$G$-$k$+$H$$$&$H5?Ld$Ge(B
e$B$9!#e(BCPUe$B$,%H%i%C%W$9$k$N$G!"$?$H$($Pe(B malloc
e$B$,5"$C$F$-$?<!$NL?Na$,%H%i%Ce(B
e$B%W$5$l$k$H$=$N%a%b%jNN0h$O%j!<%/$7$^$9!#e(B

abort() e$B$+!“e(Bfatal e$B$rEj$2$F=*N;!”$/$i$$$,4X$N;3$+$J$"$H!#e(B


#7

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:37131] Re: [Bug:1.9] 1+1+1+…+1 dumps core”
on Nov.21,2008 00:27:43, removed_email_address@domain.invalid wrote:

Windowse$B$GBeBX%9%?%C%/$r;H$($J$$$N$+$H;W$C$FD4$Y$?$i$3$s$J$N$,8+$D$+$j$^e(B
e$B$7$?!#e(B
http://www.nminoru.jp/~nminoru/programming/stackoverflow_handling.html#winnt

e$B$b$7$+$7$Fe(Bcall_cfunce$B$G9=B$2=Nc30$rJa$^$($Fe(BSystemStackErrore$B$KJQ49$7$?$j$Ge(B
e$B$-$^$9e(B?

call_cfunce$B$8$c$J$/$Fe(Brb_iseq_evale$B$NCf?H$"$?$j$r$/$/$k$N$,$$$$e(B
e$B$s$8$c$J$$$+$H;W$$$^$9$,!"$^$"$=$&$G$9!#e(B

e$B$7$+$7$3$lBeBX%9%?%C%/NN0h$J$N$+$J!#C1$K:#$V$C2u$7$?%9%?%C%/e(B
e$BNN0h$r$J$+$C$?$3$H$K$7$Fe(B__trye$B!Ae(B__excepte$B@a$N?<$5$K$^$G4,$-La$5e(B
e$B$l$F$k$5$l$F$k$@$1$N$h$&$J5$$,e(B…

e$B$=$l$G$O!#e(B


#8

On Fri, 21 Nov 2008 18:48:16 +0900
In article removed_email_address@domain.invalid
[[ruby-dev:37137] Re: [Bug:1.9] 1+1+1+…+1 dumps core]
“U.Nakamura” removed_email_address@domain.invalid wrote:

e$B$"$k$HM}2r$7$F$$$k$N$G$9$,e(B…
STATUS_STACK_OVERFLOWe$B$N>l9g$,BeBX%9%?%C%/$G!"$=$l0J30$OB3$-!"$G$9!#e(B

e$B$?$@!“BeBX%9%?%C%/$b%”%I%l%9$H$7$F$OB3$-$N0LCV$K$"$C$?$h$&$J5$$,$7$^$9e(B
e$B!J$&$m3P$(e(B

e$B%Z!<%8$H$7$F$O3NJ]$7$F$*$/$,=q9~6X;$K$7$F$"$C$F!"%H%i%C%W$9$k$H=q9~6Xe(B
e$B;
$r2r=|$9$k%$%a!<%8e(B


#9

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:37136] Re: [Bug:1.9] 1+1+1+…+1 dumps core”
on Nov.21,2008 18:02:28, removed_email_address@domain.invalid wrote:

__except( … ) e$B$N3g8LFb$r<B9TCf$O!"85$N%9%?%C%/$NB3$-!JBeBX%9%?%C%/!K$re(B
e$B;H$C$F$$$^$9!#$=$&$8$c$J$$$He(B EXCEPTION_CONTINUE_EXECUTION e$B$G:F<B9T$G$-$Je(B
e$B$$$+$i!#e(B

e$B!V85$N%9%?%C%/$NB3$-!W$C$F6qBNE*$K$I$3$K$J$k$s$G$7$g$&$+!#e(B
e$B85$N%9%?%C%/$NB3$-$,3NJ]$G$-$J$$Nc30$,e(BSTATUS_STACK_OVERFLOWe$B$Ge(B
e$B$"$k$HM}2r$7$F$$$k$N$G$9$,e(B…
e$B!VB3$-!W$N0UL#$H$$$&$+J}8~$,0c$C$?$j$7$^$9$+e(B?

e$B$=$l$G$O!#e(B


#10

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:37138] Re: [Bug:1.9] 1+1+1+…+1 dumps core”
on Nov.21,2008 19:15:01, removed_email_address@domain.invalid wrote:

__except( … ) e$B$N3g8LFb$r<B9TCf$O!"85$N%9%?%C%/$NB3$-!JBeBX%9%?%C%/!K$re(B
e$B;H$C$F$$$^$9!#$=$&$8$c$J$$$He(B EXCEPTION_CONTINUE_EXECUTION e$B$G:F<B9T$G$-$Je(B
e$B$$$+$i!#e(B

e$B$"$"!"$=$&$+!"8mFI$7$F$^$7$?!#e(B
e$B>e5-$N!Ve(B…e$B!W$r<B9T$9$k$H$-$NOC$G$9$M!#$d$C$HM}2r$G$-$^$7$?!#e(B

__excepte$B@aFb$N$3$H$@$H;W$$9~$s$G$$$?e(B

e$B$?$@!“BeBX%9%?%C%/$b%”%I%l%9$H$7$F$OB3$-$N0LCV$K$"$C$?$h$&$J5$$,$7$^$9e(B
e$B!J$&$m3P$(e(B

e$B%Z!<%8$H$7$F$O3NJ]$7$F$*$/$,=q9~6X;_$K$7$F$"$C$F!"%H%i%C%W$9$k$H=q9~6Xe(B

e$B;_$r2r=|$9$k%$%a!<%8e(B

e$B%$%a!<%8$NJ}$O$"$C$F$k$H;W$$$^$9!#e(B

e$BBeBX%9%?%C%/$NJ}$O!“B3$-$N0LCV$K$”$k$J$i!"$D$^$j$=$NB>$NNc30e(B
e$B$N>l9g$H2?$bJQ$o$i$J$$5$$,e(B…
e$BMW$9$k$Ke(BEXCEPTION_STACK_OVERFLOWe$B$,5/$-$F$b$"$He(B1e$B%Z!<%8$@$1%9%?e(B
e$B%C%/;H$($k$h$C$F$$$&$=$l$@$1$N$3$H$G$9$h$M!#e(B

e$B$=$l$G$O!#e(B


#11

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

e$B$H$$$&$o$1$G!"5?Ld$O2r>C$7$?$N$G!"e(B

In message “[ruby-dev:37133] Re: [Bug:1.9] 1+1+1+…+1 dumps core”
on Nov.21,2008 15:12:37, removed_email_address@domain.invalid wrote:

e$B$b$7$+$7$Fe(Bcall_cfunce$B$G9=B$2=Nc30$rJa$^$($Fe(BSystemStackErrore$B$KJQ49$7$?$j$Ge(B
e$B$-$^$9e(B?

call_cfunce$B$8$c$J$/$Fe(Brb_iseq_evale$B$NCf?H$"$?$j$r$/$/$k$N$,$$$$e(B
e$B$s$8$c$J$$$+$H;W$$$^$9$,!"$^$"$=$&$G$9!#e(B

e$B$H$$$&J}?K$G%Q%C%A=q$$$F$_$^$7$?!#e(B

e$B$J$s$+$S$_$g!<$Ke(Bcontrol framee$B$NCf?H$,0c$$$^$9$M!#e(B

C:>miniruby -e “eval(‘1+’*100000+‘1’)”
-e:1: [BUG] Segmentation fault
ruby 1.9.0 (2008-11-19 revision 20257) [i386-mswin32]

– control frame ----------
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :eval
c:0003 p:0017 s:0006 b:0006 l:000005 d:000005 TOP -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP

-e:1:in eval': stack level too deep (SystemStackError) from -e:1:in

Index: vm.c

— vm.c (revision 20257)
+++ vm.c (working copy)
@@ -1231,6 +1231,16 @@ vm_exec(rb_thread_t *th)

/* misc */

+#ifdef _WIN32
+static void
+w32_check_stack_overflow(DWORD code)
+{

  • if (code == EXCEPTION_STACK_OVERFLOW) {
  • raise(SIGSEGV);
  • }
    +}
    +#endif

VALUE
rb_iseq_eval(VALUE iseqval)
{
@@ -1243,7 +1253,17 @@ rb_iseq_eval(VALUE iseqval)
if (!rb_const_defined(rb_cObject, rb_intern(“TOPLEVEL_BINDING”))) {
rb_define_global_const(“TOPLEVEL_BINDING”, rb_binding_new());
}
+#ifdef _WIN32

  • __try {
    +#endif
    val = vm_exec(th);
    +#ifdef _WIN32
  • }
  • __except(w32_check_stack_overflow(GetExceptionCode()),
  •   EXCEPTION_CONTINUE_SEARCH) {
    
  • /* never comes here */
  • }
    +#endif
    tmp = iseqval; /* prohibit tail call optimization */
    return val;
    }

e$B$=$l$G$O!#e(B


#12

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

At Mon, 17 Nov 2008 00:04:12 +0900,
Hiro Y. wrote in [ruby-dev:37102]:

c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP :17

-e:1:in eval': stack level too deep (SystemStackError) from -e:1:in

e$B$J$<$H$/$K%A%’%C%/$b$7$F$$$J$$$N$Ke(BSystemStackErrore$B$K$J$C$F$$$k$Ne(B
e$B$+5?Ld$@$C$?$N$G$9$,!“BeBX%9%?%C%/>e$G%a%=%C%I$r8F$S=P$7$F$$$k:]e(B
e$B$K%9%?%C%/%A%’%C%/$7$F$$$k$N$G!”$3$l$G$O$9$Y$F$Ne(Brb_buge$B$,>o$Ke(B
SystemStackErrore$B$K$J$C$F$7$^$$$^$9!#e(B

$ .i686-linux/miniruby -e Exception.abort!
-e:1: [BUG] Segmentation fault
ruby 1.9.0 (2008-11-26 revision 20367) [i686-linux]

– control frame ----------
c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC :abort!
c:0003 p:0015 s:0006 b:0006 l:000005 d:000005 TOP -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP :17

-e:1:in abort!': stack level too deep (SystemStackError) from -e:1:in

e$B$7$+$b!"BeBX%9%?%C%/$G$b$5$i$K%*!<%P!<%U%m!<$7$F%R!<%W$r2u$7$F$$e(B
e$B$^$9!#e(B

e$BBeBX%9%?%C%/$r;H$&$3$H$@$1$J$i6K4JC1$JOC$G!"LdBj$O%9%?%C%/%*!<%P!<e(B
e$B%U%m!<$+$I$&$+$r$-$A$s$H%]!<%?%V%k$KH=CG$9$kJ}K!$G$9!#e(B


#13

e$B%A%1%C%He(B #702 e$B$,99?7$5$l$^$7$?!#e(B (by Yukihiro M.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B

fixed by r20293 (on linux).


http://redmine.ruby-lang.org/issues/show/702