[#11073] segfault printing instruction sequence for iterator — <noreply@...>

Bugs item #10527, was opened at 2007-05-02 14:42

14 messages 2007/05/02
[#11142] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Nobuyoshi Nakada <nobu@...> 2007/05/10

Hi,

[#11188] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Paul Brannan <pbrannan@...> 2007/05/16

On Thu, May 10, 2007 at 04:51:18PM +0900, Nobuyoshi Nakada wrote:

[#11234] Planning to release 1.8.6 errata — Urabe Shyouhei <shyouhei@...>

Hi all.

17 messages 2007/05/25

[ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator

From: <noreply@...>
Date: 2007-05-11 06:34:03 UTC
List: ruby-core #11153
Bugs item #10527, was opened at 2007-05-03 04:42
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10527&group_id=426

Category: Core
Group: 1.9.x
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: Paul Brannan (cout)
>Assigned to: Nobuyoshi Nakada  (nobu)
Summary: segfault printing instruction sequence for iterator

Initial Comment:
The following program segfaults:

i = VM::InstructionSequence.compile('for a in b; end')
p i.to_a

This appears to be the culprit:

                | keyword_for for_var keyword_in
                  {COND_PUSH(1);}
                  expr_value do
                  {COND_POP();}
                  compstmt
                  keyword_end
                    {
                    /*%%%*/
                        ID id = internal_id();
                        ID *tbl = ALLOC_N(ID, 2);
                        NODE *args = NEW_ARGS(1 /* m */, 0 /* o */);
                        NODE *init;
                        NODE *scope = NEW_NODE(NODE_SCOPE, tbl, $8, args);
                        tbl[0] = 1; tbl[1] = id;

                        init = node_assign($2, NEW_DVAR(id));
                        args->nd_next = NEW_ARGS_AUX(0, 0);
                        args->nd_next->nd_next = NEW_ARGS_AUX(0, 0);
                        args->nd_next->nd_next->nd_next = init;

                        $$ = NEW_FOR(0, $5, scope);
                        fixpos($$, $2);

The internal id gets added to the node, then later passed on to the instruction sequence.  When ruby tries to print out the internal id, it can't, because there is no associated string with an internal id.

This indicates to me two problems:
  - I think this is a problem with the internal_id() function in general; internal IDs don't behave like other IDs
  - the rb_id2name function can return 0 on failure or in the case that the given id is an internal id.  There are a number of places in the code where the return value isn't being checked, which could potentially cause a crash.

I do not know YARV well enough to provide a patch.


----------------------------------------------------------------------

Comment By: Nobuyoshi Nakada  (nobu)
Date: 2007-05-11 15:34

Message:
This bug is fixed in the repository.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10527&group_id=426

In This Thread

Prev Next