# Loop{x+=1&&next} dumps core

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

1.9 e\$B\$G0J2<\$N\$h\$&\$K\$9\$k\$HMn\$A\$^\$9!#e(B

## DBG> : “-e:1:in `loop'" DBG> : "-e:1:in`'” – backtrace of native function call (Use addr2line) – 0x80dad25 0x80f3f90 0x80d83f4 0x80d8814 0x80d8ec7 0x8059549 0x80d96c9 0x80d5364 0x80d8814 0x80d8b48 0x8059112 0x8059136 0x805d691 0x8056d8f 0xb7de6ea8 0x8056cc1

[BUG] Stack consistency error (sp: 13, bp: 12)
ruby 1.9.0 (2007-07-03) [i686-linux]

e\$B%"%!<%H\$7\$^\$7\$?e(B (core dumped)

e\$B\$"\$H!"e(Bloop{x+=1&&redo} e\$B\$G\$bMn\$A\$^\$9!#e(B

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

Yusuke ENDOH wrote:

1.9 e\$B\$G0J2<\$N\$h\$&\$K\$9\$k\$HMn\$A\$^\$9!#e(B

\$ ./ruby -e ‘loop{x+=1&&next}’

e\$B\$"\$H!"e(Bloop{x+=1&&redo} e\$B\$G\$bMn\$A\$^\$9!#e(B

e\$B!!\$?\$H\$(\$P!"e(B1.times{1+(1&&next)}
e\$B\$G\$b5/\$-\$^\$9!#\$D\$^\$j!“2?\$i\$+e(B
e\$B\$NCM\$,@Q\$^\$l\$F\$\$\$k>uBV\$G!“e(Bnexte\$B!Je(Bjumpe\$B!K\$9\$k\$H!”\$=\$N%4%_\$,;D\$C\$Fe(B
e\$B\$7\$^\$&!”\$H\$\$\$&>I>u\$G\$9!#e(B

e\$B!!\$3\$l\$O:\$\$j\$^\$7\$?!#\$&\$^\$\$2r7hJ}K!\$,;W\$\$\$D\$-\$^\$;\$s!#e(B

e\$B!!\$J\$s\$H\$\$\$&\$+!"Nc\$(\$Pe(B 1 + (f?next:0)
e\$B\$J\$s\$+\$O%(%i!<\$J\$N\$G!“e(B1+
(1&&next) e\$B\$b%(%i!<\$H\$J\$C\$F\$/\$l\$k\$HNI\$\$\$H;W\$&\$s\$G\$9\$,!”%@%a\$Ge(B
e\$B\$7\$g\$&\$+!#e(B

# Index: parse.y

— parse.y (e\$B%j%S%8%g%se(B 12679)
+++ parse.y (e\$B:n6H%3%T!<e(B)
@@ -7452,8 +7452,6 @@ node_assign_gen(struct parser_params *pa
static int
value_expr_gen(struct parser_params *parser, NODE *node)
{

• int cond = 0;
• while (node) {
switch (nd_type(node)) {
case NODE_DEFN:
@@ -7466,7 +7464,7 @@ value_expr_gen(struct parser_params *par
case NODE_NEXT:
case NODE_REDO:
case NODE_RETRY:
• `````` if (!cond) yyerror("void value expression");
``````
• `````` yyerror("void value expression");
/* or "control never reach"? */
return Qfalse;
``````

@@ -7488,7 +7486,6 @@ value_expr_gen(struct parser_params *par

`````` case NODE_AND:
case NODE_OR:
``````
• `````` cond = 1;
node = node->nd_2nd;
break;
``````

e\$B!!\$7\$+\$7!"1sF#\$5\$s\$h\$/\$3\$s\$J\$N8+\$D\$1\$i\$l\$^\$9\$M!#\$d\$C\$Q\$j%3!<%Ie(B
[email protected]:::\$5\$l\$F\$k\$s\$G\$7\$g\$&\$+!#e(B

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

In message “Re: [ruby-dev:31120] Re: loop{x+=1&&next} dumps core”
on Wed, 4 Jul 2007 00:20:59 +0900, SASADA Koichi [email protected]
writes:

|e\$B!!\$?\$H\$(\$P!"e(B1.times{1+(1&&next)} e\$B\$G\$b5/\$-\$^\$9!#\$D\$^\$j!“2?\$i\$+e(B
|e\$B\$NCM\$,@Q\$^\$l\$F\$\$\$k>uBV\$G!“e(Bnexte\$B!Je(Bjumpe\$B!K\$9\$k\$H!”\$=\$N%4%_\$,;D\$C\$Fe(B
|e\$B\$7\$^\$&!”\$H\$\$\$&>I>u\$G\$9!#e(B
|
|e\$B!!\$3\$l\$O:\$\$j\$^\$7\$?!#\$&\$^\$\$2r7hJ}K!\$,;W\$\$\$D\$-\$^\$;\$s!#e(B

e\$B\$&!<\$`!#e(B

|e\$B!!\$J\$s\$H\$\$\$&\$+!"Nc\$(\$Pe(B 1 + (f?next:0) e\$B\$J\$s\$+\$O%(%i!<\$J\$N\$G!“e(B1+
|(1&&next) e\$B\$b%(%i!<\$H\$J\$C\$F\$/\$l\$k\$HNI\$\$\$H;W\$&\$s\$G\$9\$,!”%@%a\$Ge(B
|e\$B\$7\$g\$&\$+!#e(B

e\$B\$(!<\$H!"e(B

xxx or next

e\$B\$H\$+\$"\$j\$=\$&\$K;W\$&\$N\$G!"[email protected]\$H\$"\$^\$j\$&\$l\$7\$/\$J\$\$\$+\$b\$7\$l\$^e(B
e\$B\$;\$s!#\$H\$\$\$&\$o\$1\$G!"e(Band e\$B\$N%*%Z%i%s%I\$KEP>l\$7\$?\$i\$9\$Y\$F%(%i!<e(B
[email protected]\$H%D%i\$\$\$N\$G\$9\$,!“e(Band e\$B\$J\$I\$,<0\$NCf\$K4^\$^\$l\$F\$\$\$?\$i%(%i!<\$He(B
e\$B\$\$\$&\$N\$O%”%[email protected]\$H;W\$\$\$^\$9!#\$I\$&\$d\$C\$F8!=P\$7\$h\$&\$+!#e(B

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

Yukihiro M. wrote:

[email protected]\$H%D%i\$\$\$N\$G\$9\$,!“e(Band e\$B\$J\$I\$,<0\$NCf\$K4^\$^\$l\$F\$\$\$?\$i%(%i!<\$He(B
e\$B\$\$\$&\$N\$O%”%[email protected]\$H;W\$\$\$^\$9!#\$I\$&\$d\$C\$F8!=P\$7\$h\$&\$+!#e(B

[email protected]\$[\$I\$N%a!<%k\$O!Ve(Band
e\$B\$J\$I\$,<0\$NCf\$K4^\$^\$l\$F\$\$\$?\$i%(%i!<!W\$re(B
e\$BDs0F\$7\$F\$*\$j\$^\$9!#@h\$[\$I\$N%a!<%k\$K=q\$\$\$?%Q%C%A\$,!"\$^\$5\$Ke(B
value_expr() e\$B\$G\$N%A%’%C%/\$r87\$7\$/\$9\$k\$b\$N\$J\$s\$G\$9\$,!"\$^\$:\$\$\$Ge(B
e\$B\$7\$g\$&\$+!#e(B

e\$B!!e(Bp(a && next)
e\$B\$H\$+!"=q\$-\$?\$\$?M\$,\$\$\$l\$P\$^\$:\$\$\$G\$9!#\$G\$9\$,!"8=e(B
e\$B>u\$G\$Oe(B p(a ? :foo : next)
e\$B\$O5v\$5\$l\$J\$\$\$N\$G!"F1\$8\$h\$&\$K5v\$5\$l\$Je(B
e\$B\$/\$F\$b\$\$\$\$\$s\$8\$c\$J\$\$\$+\$J\$!\$H;W\$\$\$^\$7\$?!#e(B