Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$!attr.^compose causing segfault #5411

Closed
p6rt opened this issue Jul 2, 2016 · 6 comments
Closed

$!attr.^compose causing segfault #5411

p6rt opened this issue Jul 2, 2016 · 6 comments
Labels
SEGV Segmentation fault, bus error, etc.

Comments

@p6rt
Copy link

p6rt commented Jul 2, 2016

Migrated from rt.perl.org#128516 (status was 'resolved')

Searchable as RT128516$

@p6rt
Copy link
Author

p6rt commented Jul 2, 2016

From @LLFourn

class Foo { has $.a = Metamodel​::ClassHOW.new_type(name => "Bar"); method
comp { $!a.^compose } };
my $obj = Foo.new;
$obj.comp;
say $obj;

Program received signal SIGSEGV, Segmentation fault.
MVM_6model_istype (tc=0x6037c0, obj=0x207fff00000001, type=0xe19b28,
res=0xea2308) at src/6model/6model.c​:287
287 st = STABLE(obj);
(gdb) bt
#​0 MVM_6model_istype (tc=0x6037c0, obj=0x207fff00000001, type=0xe19b28,
res=0xea2308) at src/6model/6model.c​:287
#​1 0x00007ffff78cecc8 in MVM_interp_run (tc=tc@​entry=0x6037c0,
initial_invoke=0x603010, invoke_data=0xe19b28) at src/core/interp.c​:1777
#​2 0x00007ffff798c589 in MVM_vm_run_file (instance=0x603010,
filename=0x7fffffffe323
"/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm")
  at src/moar.c​:304
#​3 0x0000000000401047 in main (argc=8, argv=0x7fffffffdec8) at
src/main.c​:191
(gdb) p STABLE(obj)
Cannot access memory at address 0x207fff00000011

=======
This seems to be caused by doing .^compose on a $! sigiled attribute. If
you do​: $obj.a.^compose it doesn't segfault. Also if you don't *say* the
variable at the end you get a different weird error​:

Unhandled exception​: Cannot assign to a readonly variable or a value
  at gen/moar/m-CORE.setting​:25242
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:ACCEPTS)
from gen/moar/m-CORE.setting​:22293
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:)
from gen/moar/m-CORE.setting​:22268
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:EXCEPTION)
from <unknown>​:1
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:)
from gen/moar/m-CORE.setting​:25242
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:ACCEPTS)
from gen/moar/m-CORE.setting​:25233
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:ACCEPTS)
from gen/moar/m-CORE.setting​:22293
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:)
from gen/moar/m-CORE.setting​:22268
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:EXCEPTION)
from gen/moar/m-CORE.setting​:22332
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:)
from gen/moar/m-CORE.setting​:22331
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:print_exception)
from gen/moar/m-CORE.setting​:22409
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:<anon>)
from gen/moar/m-main.nqp​:44
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:)
from <unknown>​:1
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:)
from gen/moar/m-CORE.setting​:19225
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:AT-KEY)
from gen/moar/m-CORE.setting​:6711
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:postcircumfix​:<{
}>)
from gen/moar/m-CORE.setting​:32577
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:)
from gen/moar/m-main.nqp​:42
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:MAIN)
from gen/moar/m-main.nqp​:33
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:<mainline>)
from <unknown>​:1
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:<main>)
from <unknown>​:1
(/home/llfourn/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:<entry>)

@p6rt
Copy link
Author

p6rt commented Jul 28, 2016

From @nwc10

On Fri, Jul 01, 2016 at 10​:36​:25PM -0700, Lloyd Fournier wrote​:

class Foo { has $.a = Metamodel​::ClassHOW.new_type(name => "Bar"); method
comp { $!a.^compose } };
my $obj = Foo.new;
$obj.comp;
say $obj;

When I run that, I get this​:

moar​: src/gc/roots.c​:245​: MVM_gc_root_gen2_add​: Assertion `!(c->flags & MVM_CF_FORWARDER_VALID)' failed.
Aborted

(I wasn't paying close attention, but I guess I built with full-on debugging
flags)

I hope that makes it more obvious to someone how to fix this.

Nicholas Clark

@p6rt
Copy link
Author

p6rt commented Jul 28, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jul 28, 2016

From @LLFourn

Further information​: if you put nqp​::decont($!a).^compose it works.

On Wed, Jul 6, 2016 at 4​:26 AM Nicholas Clark <nick@​ccl4.org> wrote​:

On Fri, Jul 01, 2016 at 10​:36​:25PM -0700, Lloyd Fournier wrote​:

class Foo { has $.a = Metamodel​::ClassHOW.new_type(name => "Bar"); method
comp { $!a.^compose } };
my $obj = Foo.new;
$obj.comp;
say $obj;

When I run that, I get this​:

moar​: src/gc/roots.c​:245​: MVM_gc_root_gen2_add​: Assertion `!(c->flags &
MVM_CF_FORWARDER_VALID)' failed.
Aborted

(I wasn't paying close attention, but I guess I built with full-on
debugging
flags)

I hope that makes it more obvious to someone how to fix this.

Nicholas Clark

@p6rt
Copy link
Author

p6rt commented Dec 21, 2016

From @jnthn

On Fri, 01 Jul 2016 22​:36​:25 -0700, lloyd.fourn@​gmail.com wrote​:

class Foo { has $.a = Metamodel​::ClassHOW.new_type(name => "Bar");
method
comp { $!a.^compose } };
my $obj = Foo.new;
$obj.comp;
say $obj;

Program received signal SIGSEGV, Segmentation fault.
MVM_6model_istype (tc=0x6037c0, obj=0x207fff00000001, type=0xe19b28,
res=0xea2308) at src/6model/6model.c​:287
287 st = STABLE(obj);
(gdb) bt
#​0 MVM_6model_istype (tc=0x6037c0, obj=0x207fff00000001,
type=0xe19b28,
res=0xea2308) at src/6model/6model.c​:287
#​1 0x00007ffff78cecc8 in MVM_interp_run (tc=tc@​entry=0x6037c0,
initial_invoke=0x603010, invoke_data=0xe19b28) at
src/core/interp.c​:1777
#​2 0x00007ffff798c589 in MVM_vm_run_file (instance=0x603010,
filename=0x7fffffffe323
"/home/llfourn/.rakudobrew/moar-
nom/install/share/perl6/runtime/perl6.moarvm")
at src/moar.c​:304
#​3 0x0000000000401047 in main (argc=8, argv=0x7fffffffdec8) at
src/main.c​:191
(gdb) p STABLE(obj)
Cannot access memory at address 0x207fff00000011

=======
This seems to be caused by doing .^compose on a $! sigiled attribute.

The SEGV was thanks to MoarVM accidentally allowing recomposition of a P6opaque; I added a check to forbid this and that had the code reliably failing instead of SEGVing. A second fix in the MOP code to always decontainerize the argument to the composetype op was the second part, and this code now works fine. Added a test in S12-meta/classhow.t.

/jnthn

@p6rt p6rt closed this as completed Dec 21, 2016
@p6rt
Copy link
Author

p6rt commented Dec 21, 2016

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt added the SEGV Segmentation fault, bus error, etc. label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SEGV Segmentation fault, bus error, etc.
Projects
None yet
Development

No branches or pull requests

1 participant