#185: thawed subs with :vtable don't register properly for existing classes
----------------------+-----------------------------------------------------
Reporter: jhorwitz | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: core | Version:
Severity: medium | Keywords:
Lang: | Patch:
Platform: |
----------------------+-----------------------------------------------------
Description changed by jhorwitz:
Old description:
> If a class is created before load_bytecode thaws a :vtable sub for that
> class, parrot tries to override a vtable method with the same name as the
> thawed sub. This blows up when the sub name is not a valid vtable
> function, which is common in Rakudo. Everything works in fine in pure
> PIR.
>
> At first glance, the culprit appears to be add_vtable_override() in
> src/pmc/class.pmc, which only uses the sub's name to check if it's a
> valid override. Shouldn't it also check the thawed sub's vtable_index?
>
> This breaks mod_perl6, as mod_parrot needs to load P6object before
> loading Rakudo's perl6.pbc.
>
> Test case follows.
>
> bar.pir:
> {{{
> .sub '__onload' :load
> $P0 = newclass ['Bar']
> .end
> }}}
>
> foo.pir:
> {{{
> .sub '__onload' :init
> load_bytecode 'bar.pbc'
> .end
>
> .namespace ['Bar']
>
> .sub 'invalidname' :vtable('get_string') :method
> $S0 = 'hello world'
> .return($S0)
> .end
> }}}
>
> baz.pir:
> {{{
> .sub main :main
> load_bytecode 'bar.pbc'
> load_bytecode 'foo.pbc'
> .end
> }}}
>
> Output:
> {{{
> [j...@groovy parrot]$ ./parrot -o foo.pbc foo.pir
> [j...@groovy parrot]$ ./parrot -o bar.pbc bar.pir
> [j...@groovy parrot]$ ./parrot baz1.pir
> 'invalidname' is not a valid vtable function name.
> current instr.: 'main' pc 2 (baz1.pir:3)
> }}}
New description:
If a class is created before load_bytecode thaws a :vtable sub for that
class, parrot tries to override a vtable method with the same name as the
thawed sub. This blows up when the sub name is not a valid vtable
function, which is common in Rakudo. Everything works in fine in pure
PIR.
At first glance, the culprit appears to be add_vtable_override() in
src/pmc/class.pmc, which only uses the sub's name to check if it's a valid
override. Shouldn't it also check the thawed sub's vtable_index?
This breaks mod_perl6, as mod_parrot needs to load P6object before loading
Rakudo's perl6.pbc.
Test case follows.
bar.pir:
{{{
.sub '__onload' :load
$P0 = newclass ['Bar']
.end
}}}
foo.pir:
{{{
.sub '__onload' :load
load_bytecode 'bar.pbc'
.end
.namespace ['Bar']
.sub 'invalidname' :vtable('get_string') :method
$S0 = 'hello world'
.return($S0)
.end
}}}
baz.pir:
{{{
.sub main :main
load_bytecode 'bar.pbc'
load_bytecode 'foo.pbc'
.end
}}}
Output:
{{{
[j...@groovy parrot]$ ./parrot -o foo.pbc foo.pir
[j...@groovy parrot]$ ./parrot -o bar.pbc bar.pir
[j...@groovy parrot]$ ./parrot baz1.pir
'invalidname' is not a valid vtable function name.
current instr.: 'main' pc 2 (baz1.pir:3)
}}}
--
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/185#comment:1>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets