[Yarv-devel] "a = {}; a[0] || = 1" crashes

Vincent Isambart vincent.isambart at gmail.com
Wed Feb 23 11:03:22 EST 2005


こんばんは、

> > YARV crashes with the following simple Ruby script:
> > a = {}; a[0] || = 1
> >
> > I checked it a little and it seems the error is during the compilation
> > step. I do not know YARV or the Ruby interpreter very well so I may be
> > mistaken.
> > The problem seems to be in compile.c, and there search for NODE_OP_ASGN1.
> > The error seems to be the "ADD_SEND (ret, nd_line(node),
> > ID2SYM(node->nd_mid), I2F(1));"
> > For the || and && operators, node->nd_mid's value is 0 and 1, it's not an ID...
> > If you try a parse and disassemble the "a = {}; a[0] || = 1" script,
> > you'll see that YARV will try to invoque null...
> 
> Thank you.
> I missed it! I fixed it.

Thanks for the fast correction.

But I checked your correction and there is something odd. An extract
of what you did:

    if(id == 0 || id == 1){
(...)
    }
    else if(id == 1){
      /* and */
      VALUE label = NEW_LABEL(nd_line(node));
      
      
    }
    else{
      ADD_SEQ  (ret, COMPILE("NODE_OP_ASGN1 args->head: ",
node->nd_args->nd_head));
      ADD_SEND (ret, nd_line(node), ID2SYM(id), I2F(1));
      ADD_SEND (ret, nd_line(node), ID2SYM(idASET), I2F(argc+1));
    }

I think the "else if(id == 1)" is useless... This branch will never be
executed :P

Kind regards,
おやすみなさい、
Vincent Isambart



More information about the Yarv-devel mailing list