lua: Unexpected NULL with nested self references

Jonathan "Duke" Leto jonathan at leto.net
Fri Jul 29 16:42:30 UTC 2011


Howdy,

Thanks for the bug report!

This looks like it will be a good test case. I will wait for fperrad++
to weigh in on what the correct behavior in this instance should be.

Duke

On Fri, Jul 29, 2011 at 1:39 AM, Aaron Faanes <dafrito at gmail.com> wrote:
> (If there's a better list for this, let me know and ignore the rest ;) )
>
> I ran into a problem compiling some old lua code I had lying around. I
> managed to isolate the cause of the exception in the following example:
>
> ---
>
> local instance = {};
>
> function instance:Constructor()
>     function self:Bar() end;
>     function self:Bar() end; -- Null PMC access here!
> end;
>
> instance:Constructor()
>
> ---
>
> I receive the following exception:
>
> lua.pbc: nullpmc.lua:5: Null PMC access in set_pmc_keyed()
> stack traceback:
>     nullpmc.lua:5: in function 'instance.Constructor_13'
>     nullpmc.lua:8: in main chunk
>     [PIR]: in function 'docall'
>     [PIR]: in function 'handle_script'
>     [PIR]: in function 'main'
>
> I've been picking apart the generated code, trying to see what's causing the
> issue. The null
> access is due to the generated PIR referring to "self" in two different
> ways. The following
> is, hopefully, a useful snippet:
>
> .annotate 'line', 4
>     .const "Sub" fct_17 = "post18"
>     newclosure $P19, fct_17
>     $P20 = subr."getfenv"()
>     $P19."setfenv"($P20)
>     set param_self_1[k_Bar], $P19
> .annotate 'line', 5
>     .const "Sub" fct_23 = "post24"
>     newclosure $P25, fct_23
>     $P26 = subr."getfenv"()
>     $P25."setfenv"($P26)
>     find_lex $P27, "self_2"
>     set $P27[k_Bar], $P25
>
> As you can see, the first use of self is "param_self_1", which is expected,
> but the second use of
> self is the non-existent "self_2".
>
> If you look at the PAST generated, "self_2" can be found inside self:Bar()
> as the unique name for the
> implicit self. I haven't been able to determine how that name managed to
> pollute the outer symbol table.
>
> I hope this bug report helps! Let me know if I should file this somewhere
> (or if I require a sanity check).
>
> --
> Aaron Faanes <dafrito at gmail.com>
>
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>
>



-- 
Jonathan "Duke" Leto <jonathan at leto.net>
Leto Labs LLC
209.691.DUKE // http://labs.leto.net
NOTE: Personal email is only checked twice a day at 10am/2pm PST,
please call/text for time-sensitive matters.


More information about the parrot-dev mailing list