[Bug #943] Segmentation fault (cygwin)


#1

Bug #943: Segmentation fault (cygwin)
http://redmine.ruby-lang.org/issues/show/943

e$B5/I<<Te(B: Martin De$(D+de(Brst
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal

e$B<!$N%9%/%j%W%H$,e(B Segmentation fault (core dumped)
e$B$G=*$o$j$^$9!#e(B

ruby -e ‘puts “A=[”; 0.upto(1000000) { puts " [22, 55]," }; puts “]”’ |
ruby

[ruby-dev:37611] e$B$GJs9p$7$?LdBj$r4JC12=$7$^$7$?!#LdBj$O:8B&$Ne(B ruby
e$B$N$G$O$J$/!"e(B
e$B1&B&$Ne(B ruby e$B$G5/$3$j$^$9!#e(B

e$B$h$m$7$/$*4j$$$7$^$9!#e(B Martin.


#2

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

Martin Du"rst wrote::

e$B<!$N%9%/%j%W%H$,e(B Segmentation fault (core dumped) e$B$G=*$o$j$^$9!#e(B

ruby -e ‘puts “A=[”; 0.upto(1000000) { puts " [22, 55]," }; puts “]”’ | ruby

[ruby-dev:37611] e$B$GJs9p$7$?LdBj$r4JC12=$7$^$7$?!#LdBj$O:8B&$Ne(B ruby e$B$N$G$O$J$/!"e(B
e$B1&B&$Ne(B ruby e$B$G5/$3$j$^$9!#e(B

e$B!!%9%?%C%/%*!<%P!<%U%m!<%A%’%C%/$,B-$j$F$$$^$;$s$G$7$?!%B?J,!$$3$l$GD>$je(B
e$B$^$9!%<j85$G$OD>$j$^$7$?!%e(B[ruby-dev:37611]
e$B$N$[$&$O;n$7$F$$$J$$$N$G$9e(B
e$B$,!$8+$F$b$i$($^$;$s$+!%e(B

Index: vm.c

— vm.c (e$B%j%S%8%g%se(B 21150)
+++ vm.c (e$B:n6H%3%T!<e(B)
@@ -77,6 +77,8 @@ vm_set_top_stack(rb_thread_t * th, VALUE
vm_push_frame(th, iseq, VM_FRAME_MAGIC_TOP,
th->top_self, 0, iseq->iseq_encoded,
th->cfp->sp, 0, iseq->local_size);
+

  •    CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max);
    

}

static void
@@ -95,6 +97,8 @@ vm_set_eval_stack(rb_thread_t * th, VALU
if (cref) {
th->cfp->dfp[-1] = (VALUE)cref;
}
+

  • CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max);
    }

static void
@@ -116,6 +120,8 @@ vm_set_main_stack(rb_thread_t *th, VALUE
if (bind && iseq->local_size > 0) {
bind->env = vm_make_env_object(th, th->cfp);
}
+

  • CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max);
    }

rb_control_frame_t *


#3

e$B%A%1%C%He(B #943 e$B$,99?7$5$l$^$7$?!#e(B (by Koichi Sasada)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r21163.

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


#4

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

Martin D. wrote::

e$B$KD>$9$H!";~4V$,$+$+$k$b$N$N!"LdBj$J$/40@.$5$l$^$9!#e(B
e$B!!e(B[e1, e2, …, eN] e$B$H$$$&%j%F%i%k$O!$0lEYe(B e1, e2, …, eN
e$B$rA4It%9%?%Ce(B
e$B%/$K@Q$s$G!$%9%?%C%/>e$NCM$rMxMQ$7$FG[Ns$r:n$j$^$9!%$=$N$?$a!$%9%?%C%/e(B
e$B%*!<%P!<%U%m!<$K$J$j$^$9!%e(B

e$B!!>e5-Nc$N$h$&$K!$6u$NG[Ns$r:n$C$F!$$=$l$Ke(B push
e$B$9$k$h$&$KJQ99$9$k$3$H$be(B
e$B2DG=$G$9$,!$$=$l$r=PMh$k$h$&$K$7$?$[$&$,$$$$$G$9$+$M$’!%$9$k$K$7$F$b!$e(B
1.9.2
e$B$GL?NaDI2C$C$F$3$H$K$J$k$H;W$$$^$9$,!%$=$&JQ99$7$?$i!$$A$g$C$HB.EYe(B
e$B$,CY$/$J$k$C$F$/$i$$$+$J$!!%e(B


#5

e$B:{ED$5$s!"$3$s$K$A$O!#e(B

At 16:18 08/12/29, SASADA Koichi wrote:

e$B!!%9%?%C%/%*!<%P!<%U%m!<%A%’%C%/$,B-$j$F$$$^$;$s$G$7$?!%B?J,!$$3$l$GD>$je(B
e$B$^$9!%<j85$G$OD>$j$^$7$?!%e(B[ruby-dev:37611] e$B$N$[$&$O;n$7$F$$$J$$$N$G$9e(B
e$B$,!$8+$F$b$i$($^$;$s$+!%e(B

e$B0J2<$N=$@5$G>e5-$NLdBj$be(B [ruby-dev:37611] e$B$bD>$C$F$$$^$9!#e(B
e$B$H$$$&$N$O!“e(BSegmentation fault e$B$+$ie(B SystemStackError
e$B$Ke(B
e$BJQ$o$C$?$@$1$G$9!#$=$NJ}$,$$$$$G$9$N$G!”@'Hs2<5-$N%Q%C%A$re(B
e$B%3%_%C%H$7$F$/$@$5$$!#e(B

e$B$7$+$7!"??$CJ?$i$J%G!<%?$rFI$_9~$`$@$1$G%9%?%C%/$,$3$s$J$K?-$S$ke(B
e$B$N$O$J$<$G$7$g$&$+!#>e5-$N%9%/%j%W%H$re(B

ruby -e ‘puts “A=[]”; 0.upto(1000000) { puts “A<<[22, 55]” }’ | ruby

e$B$KD>$9$H!";~4V$,$+$+$k$b$N$N!"LdBj$J$/40@.$5$l$^$9!#e(B

e$B$h$m$7$/$*4j$$$7$^$9!#e(B Martin.

}
static void


// SASADA Koichi at atdot dot net

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-# http://www.sw.it.aoyama.ac.jp mailto:removed_email_address@domain.invalid


#6

At 17:19 08/12/29, SASADA Koichi wrote:

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

Martin D. wrote::

e$B$7$+$7!"??$CJ?$i$J%G!<%?$rFI$_9~$`$@$1$G%9%?%C%/$,$3$s$J$K?-$S$ke(B
e$B$N$O$J$<$G$7$g$&$+!#>e5-$N%9%/%j%W%H$re(B

ruby -e ‘puts “A=[]”; 0.upto(1000000) { puts “A<<[22, 55]” }’ | ruby

e$B$KD>$9$H!";~4V$,$+$+$k$b$N$N!"LdBj$J$/40@.$5$l$^$9!#e(B

e$B!!e(B[e1, e2, …, eN] e$B$H$$$&%j%F%i%k$O!$0lEYe(B e1, e2, …, eN e$B$rA4It%9%?%Ce(B
e$B%/$K@Q$s$G!$%9%?%C%/>e$NCM$rMxMQ$7$FG[Ns$r:n$j$^$9!%$=$N$?$a!$%9%?%C%/e(B
e$B%*!<%P!<%U%m!<$K$J$j$^$9!%e(B

e$B$=$N$0$i$$$OA[A|$,IU$-$^$7$?!#e(B

e$B!!>e5-Nc$N$h$&$K!$6u$NG[Ns$r:n$C$F!$$=$l$Ke(B push e$B$9$k$h$&$KJQ99$9$k$3$H$be(B
e$B2DG=$G$9$,!$$=$l$r=PMh$k$h$&$K$7$?$[$&$,$$$$$G$9$+$M$’!%$9$k$K$7$F$b!$e(B
1.9.2 e$B$GL?NaDI2C$C$F$3$H$K$J$k$H;W$$$^$9$,!%$=$&JQ99$7$?$i!$$A$g$C$HB.EYe(B
e$B$,CY$/$J$k$C$F$/$i$$$+$J$!!%e(B

e$B$3$s$J$K$G$+$$!VDj?t!W$NG[Ns$O$I$N$0$i$$I,MW$K$J$k$N$+$OJ,$+$j$^$;$s$,!“e(B
e$B!VDj?t$+$iDI2C$K5-=R$rJQ99$7$F$/$@$5$$!#!W$H8@$&I,MW$,$G$F$/$k$N$Oe(B
e$B2?$H$J$/5U$N$h$&$J5$$,$9$k!#$^$”!"e(B1.9.2
e$B$H$+$NCJ3,$G$8$C$/$j9M$($?e(B
e$BJ}$,$$$$$H;W$$$^$9!#e(B

e$B$h$m$7$/$*4j$$$7$^$9!#e(B Martin.

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-# http://www.sw.it.aoyama.ac.jp mailto:removed_email_address@domain.invalid