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

Null PMC access (Parrot) and segfault (JVM) when assigning to a variable "declared" in a subsignature in a variable declaration in Rakudo #3260

Closed
p6rt opened this issue Oct 28, 2013 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Oct 28, 2013

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

Searchable as RT120397$

@p6rt
Copy link
Author

p6rt commented Oct 28, 2013

From @masak

<BenGoldberg> r​: my $a ($b, $c); $b = 42; say $b
<camelia> rakudo-parrot 3cef56​: OUTPUT«(signal SEGV)»
<camelia> ..rakudo-jvm 882e33​: OUTPUT«java.lang.NullPointerException [...]
<masak> whoa.
* masak submits rakudobug
<masak> r​: my $a ($b, $c); $b = 42
<camelia> rakudo-jvm 882e33​: OUTPUT«java.lang.NullPointerException [...]
<camelia> ..rakudo-parrot 3cef56​: OUTPUT«(signal SEGV)»
<jnthn> I'm surprised it even parses; I must be misremembering
something in the grammar...
<TimToady> it's just coming in as a postconstraint
<jnthn> oh...
<jnthn> I suspect we don't try to handle that code path at all :)
<jnthn> So heck knows what comes of the $b and $c... :)
<TimToady> r​: my $a where 42; $a = 43
<camelia> rakudo-parrot 3cef56, rakudo-jvm 882e33​: ( no output )
<TimToady> yeah

@p6rt
Copy link
Author

p6rt commented Oct 17, 2014

From @usev6

Status update​: Right now this is no longer a Null PMC access error on Parrot but we get a segfault on Moar as well​:

$ perl6-m -e 'my $a ($b, $c); $b = 42;'
Segmentation fault

$ perl6-p -e 'my $a ($b, $c); $b = 42;'
Cannot assign to an immutable value
  in block <unit> at -e​:1

$ perl6-j -e 'my $a ($b, $c); $b = 42;'
java.lang.NullPointerException
  in block <unit> at -e​:1

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 17, 2014

From @usev6

Status update​: Right now this is no longer a Null PMC access error on Parrot but we get a segfault on Moar as well​:

$ perl6-m -e 'my $a ($b, $c); $b = 42;'
Segmentation fault

$ perl6-p -e 'my $a ($b, $c); $b = 42;'
Cannot assign to an immutable value
  in block <unit> at -e​:1

$ perl6-j -e 'my $a ($b, $c); $b = 42;'
java.lang.NullPointerException
  in block <unit> at -e​:1

@p6rt
Copy link
Author

p6rt commented Oct 17, 2014

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 21, 2014

From @nwc10

On Fri, Oct 17, 2014 at 03​:08​:12AM -0700, Christian Bartolomaeus via RT wrote​:

Status update​: Right now this is no longer a Null PMC access error on Parrot but we get a segfault on Moar as well​:

$ perl6-m -e 'my $a ($b, $c); $b = 42;'
Segmentation fault

valgrind doesn't spot any undefined behaviour leading up to the SEGV​:

==2246== Invalid read of size 8
==2246== at 0x4F57A5E​: MVM_interp_run (interp.c​:1226)
==2246== by 0x502FBA3​: MVM_vm_run_file (moar.c​:208)
==2246== by 0x40110D​: main (main.c​:191)
==2246== Address 0x10 is not stack'd, malloc'd or (recently) free'd
==2246==
==2246==
==2246== Process terminating with default action of signal 11 (SIGSEGV)​: dumping core
==2246== Access not within mapped region at address 0x10
==2246== at 0x4F57A5E​: MVM_interp_run (interp.c​:1226)
==2246== by 0x502FBA3​: MVM_vm_run_file (moar.c​:208)
==2246== by 0x40110D​: main (main.c​:191)

It's this code (with line numbers)​:

  1223 OP(assign)​: {
  1224 MVMObject *cont = GET_REG(cur_op, 0).o;
  1225 MVMObject *obj = GET_REG(cur_op, 2).o;
  1226 const MVMContainerSpec *spec = STABLE(cont)->container_spec;
  1227 cur_op += 4;
  1228 if (spec) {
  1229 spec->store(tc, cont, obj);
  1230 } else {
  1231 MVM_exception_throw_adhoc(tc, "Cannot assign to an immutable value");
  1232 }
  1233 goto NEXT;

I can't convince gdb to "like" the various local libraries on this machine
(local updated compiler toolchain, but not debugger), so I can't verify which
pointer is NULL.

Nicholas Clark

@p6rt
Copy link
Author

p6rt commented Mar 4, 2015

From @donaldh

2015.02 gives this result on both Moar and JVM​:

my $a ($b, $c); $b = 42; say $b
===SORRY!=== Error while compiling <unknown file>
Post-constraints on variables not yet implemented. Sorry.
at <unknown file>​:1
------> my $a ($b, $c)⏏; $b = 42; say $b
  expecting any of​:
  constraint

This ticket can probably be closed.

@p6rt
Copy link
Author

p6rt commented Mar 11, 2015

From @usev6

I added a test to S04-declarations/my.t with commit Raku/roast@25f2964446

It only tests that there is no NullPointerException (or no segfault which would abort the test) -- everything else passes.

I'm closing this ticket as 'resolved'.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Mar 11, 2015

From @usev6

I added a test to S04-declarations/my.t with commit Raku/roast@25f2964446

It only tests that there is no NullPointerException (or no segfault which would abort the test) -- everything else passes.

I'm closing this ticket as 'resolved'.

@p6rt
Copy link
Author

p6rt commented Mar 11, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant