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

Pre-compiled MoarVM-code segfaults on type-checking #4261

Closed
p6rt opened this issue May 25, 2015 · 7 comments
Closed

Pre-compiled MoarVM-code segfaults on type-checking #4261

p6rt opened this issue May 25, 2015 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 25, 2015

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

Searchable as RT125245$

@p6rt
Copy link
Author

p6rt commented May 25, 2015

From andrspv@gmail.com

Dummy.pm​:

  use File​::Temp;
  class Dummy {
  subset File of Str where -> $x { so $x && $x.IO.e };
  has File $!in;
  method BUILD() { $!in = tempfile[0] }
  method method { "OKAY" }
  }
 
main.pl​:

  use Dummy;
  my $v = Dummy.new;
  say $v.method;
 

% perl6 --target=mbc --output=blib/Dummy.pm.moarvm lib/Dummy.pm
% perl6 -Ilib main.pl
OKAY
% perl6 -Iblib main.pl
Segmentation fault

Backtrace​:

(gdb) bt full
#​0 MVM_6model_find_method_cache_only (tc=tc@​entry=0x602700,
obj=obj@​entry=0x0, name=0x611220) at src/6model/6model.c​:26
  cache = 0x0
#​1 0x00007ffff5d4e0f9 in rakudo_scalar_store (tc=0x602700,
cont=0x7ffff63b2298, obj=0x7ffff6454710)
  at src/vm/moar/ops/container.c​:133
  HOW = 0x0
  meth = <optimized out>
  mode = <optimized out>
  rs = 0x7ffff63b2298
  rcd = 0x2c16500
  rw = <optimized out>
#​2 0x00007ffff7927b0e in MVM_interp_run (tc=0x602700,
initial_invoke=0x602010, invoke_data=0x611220) at
src/core/interp.c​:1225
  cont = 0x0
  obj = 0x611220
  spec = 0x197b7f0
  op = 4640
  LABELS = {0x7ffff7917a11, 0x7ffff79236c7, 0x7ffff7917a74,
0x7ffff7917a74, 0x7ffff7923c9d, 0x7ffff7923ce0,
  0x7ffff792388c, 0x7ffff79238d1, 0x7ffff7920896,
0x7ffff7921612, 0x7ffff7921617, 0x7ffff792161c, 0x7ffff7921625,
  0x7ffff7921635, 0x7ffff7921645, 0x7ffff7921655,
0x7ffff7921665, 0x7ffff7921d46, 0x7ffff7921d4b, 0x7ffff791d621,
  0x7ffff791d626, 0x7ffff7917a42, 0x7ffff7917a48,
0x7ffff7921b74, 0x7ffff7921ab5, 0x7ffff7921b18, 0x7ffff7921506,
  0x7ffff792156f, 0x7ffff792183e, 0x7ffff79218ae,
0x7ffff7921675, 0x7ffff79216e8, 0x7ffff7921762, 0x7ffff79217cc,
  0x7ffff7925d5f, 0x7ffff79208dd, 0x7ffff792095f,
0x7ffff79209d6, 0x7ffff79236cc, 0x7ffff7923738, 0x7ffff79237a2,
  0x7ffff792381d, 0x7ffff7923c2c, 0x7ffff7923b42,
0x7ffff7923bb1, 0x7ffff7917a8a, 0x7ffff7917a8a, 0x7ffff7925e6c,
  0x7ffff7925a2a, 0x7ffff79264d7, 0x7ffff79279a4,
0x7ffff791d501, 0x7ffff7923551, 0x7ffff79235b5, 0x7ffff7923618,
  0x7ffff792367b, 0x7ffff7924725, 0x7ffff79248d7,
0x7ffff792492b, 0x7ffff7924779, 0x7ffff79247cd, 0x7ffff7924821,
  0x7ffff792638f, 0x7ffff7923923, 0x7ffff7923972,
0x7ffff79239c1, 0x7ffff7923a11, 0x7ffff7923a8f, 0x7ffff7923ae0,
  0x7ffff7923cf6, 0x7ffff7923d48, 0x7ffff7923d92,
0x7ffff7923de6, 0x7ffff7923e26, 0x7ffff7923e66, 0x7ffff7923ea6,
  0x7ffff7925790, 0x7ffff79256f4, 0x7ffff79258c5,
0x7ffff7925829, 0x7ffff7925873, 0x7ffff792504a, 0x7ffff7925f71,
  0x7ffff79260da, 0x7ffff791a669, 0x7ffff791b56e,
0x7ffff7924875, 0x7ffff792497f, 0x7ffff79249dd, 0x7ffff7917b85,
  0x7ffff7917bdb, 0x7ffff7917c32, 0x7ffff792664f,
0x7ffff79244a7, 0x7ffff79244f9, 0x7ffff792454b, 0x7ffff792459d,
  0x7ffff79245ef, 0x7ffff792467d, 0x7ffff79246ce,
0x7ffff7925ecb, 0x7ffff7927a29, 0x7ffff7927a78, 0x7ffff791a1d9,
  0x7ffff791a228, 0x7ffff791a279, 0x7ffff791a2c8,
0x7ffff791a319, 0x7ffff791a368, 0x7ffff791a3b7, 0x7ffff791a411,
  0x7ffff791a46c, 0x7ffff791a4c5, 0x7ffff791a516,
0x7ffff791a567, 0x7ffff791a5b6, 0x7ffff791a613, 0x7ffff791c1b8,
  0x7ffff791c209, 0x7ffff79257df, 0x7ffff7925743,
0x7ffff7925a86, 0x7ffff7925add, 0x7ffff7925b35, 0x7ffff7925b8c,
  0x7ffff7925be4, 0x7ffff7925c43, 0x7ffff7923f39,
0x7ffff7923f89, 0x7ffff7923fe0, 0x7ffff7924039, 0x7ffff7924090,
  0x7ffff7924b3d, 0x7ffff7924b88, 0x7ffff7924bd5,
0x7ffff79240e7, 0x7ffff7924197, 0x7ffff792425b, 0x7ffff792431f,
  0x7ffff79243e3, 0x7ffff7924c2f, 0x7ffff7924c86,
0x7ffff7924d18, 0x7ffff7924db4, 0x7ffff7924e46, 0x7ffff7924ed8,
  0x7ffff7924f8c, 0x7ffff7925914, 0x7ffff792509c,
0x7ffff7925150, 0x7ffff79251f1, 0x7ffff792529c, 0x7ffff792533d,
  0x7ffff79253de, 0x7ffff79254a1, 0x7ffff792556e,
0x7ffff7925631, 0x7ffff7925ca2, 0x7ffff79259c8, 0x7ffff7923ee6,
  0x7ffff7925dd5, 0x7ffff7925f25, 0x7ffff7925d08,
0x7ffff79263f1, 0x7ffff792644c, 0x7ffff7925fee, 0x7ffff7926079,
  0x7ffff79262bb, 0x7ffff7926325, 0x7ffff7926128,
0x7ffff7926192, 0x7ffff79261f3, 0x7ffff7926257, 0x7ffff791d564,
  0x7ffff791d5c1, 0x7ffff792673b, 0x7ffff792679b,
0x7ffff791f704, 0x7ffff791f65d, 0x7ffff79267fa, 0x7ffff7926859,
  0x7ffff79268ab, 0x7ffff7927c1d, 0x7ffff7926915,
0x7ffff7926968, 0x7ffff79269bb, 0x7ffff7926a29, 0x7ffff7926ad7,
  0x7ffff7926b85, 0x7ffff79282d7, 0x7ffff7927de0,
0x7ffff791f0e5, 0x7ffff792061f, 0x7ffff7928385, 0x7ffff79278de,
  0x7ffff7927945, 0x7ffff79185b8, 0x7ffff7918368,
0x7ffff7926e4a, 0x7ffff7926ea9...}
  cur_op = 0x7ffff523b9e3 "\001\004\006"
  bytecode_start = 0x7ffff523b8ff "\214"
  reg_base = 0x969d90
  cu = 0x65d988
  cur_callsite = 0x7ffff7dcc680
#​3 0x00007ffff79be18b in MVM_vm_run_file (instance=0x602010,
  filename=0x7fffffffe778
"/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm")
at src/moar.c​:218
  start_frame = <optimized out>
  tc = 0x602700
  cu = 0x65c4b0
#​4 0x000000000040103d in main (argc=8, argv=0x7fffffffe308) at src/main.c​:189
  instance = 0x602010
  input_file = 0x7fffffffe778
"/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm"
  executable_name = <optimized out>
  lib_path = {0x7fffffffe6ae
"/home/andreoss/.rakudobrew/moar-nom/install/share/nqp/lib",
  0x7fffffffe6f2
"/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/lib",
  0x7fffffffe738
"/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime",
0x0, 0x7fffffffe20f "",
  0x400b31 "H\203\304", <incomplete sequence \303>, 0x1
<Address 0x1 out of bounds>,
  0x4011cd
"H\203\303\001H9\353r\352H\213\\$\bH\213l$\020L\213d$\030L\213l$
L\213t$(L\213|$0H\203\304\070Ð\220\220H\203\354\bH\203\304",
<incomplete sequence \303>}
  dump = <optimized out>
  full_cleanup = <optimized out>
  argi = 6
  lib_path_i = <optimized out>
  flag = 6299664

(gdb) print MVM_dump_backtrace(tc)
  at <unknown>​:1
(/home/andreoss/dev/p6/segfault/blib/Dummy.pm.moarvm​:BUILD​:4294967295)
from src/gen/m-CORE.setting​:1031
(/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​::70)
from src/gen/m-CORE.setting​:1025
(/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:BUILDALL​:68)
from src/gen/m-CORE.setting​:1014
(/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:bless​:37)
from src/gen/m-CORE.setting​:1000
(/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:new​:20)
from src/gen/m-CORE.setting​:999
(/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm​:new​:39)
from main.pl​:3 (<ephemeral file>​:<unit>​:25)
from main.pl​:1 (<ephemeral file>​:<unit-outer>​:10)
from gen/moar/stage2/NQPHLL.nqp​:1289
(/home/andreoss/.rakudobrew/moar-nom/install/share/nqp/lib/NQPHLL.moarvm​:eval​:190)
from gen/moar/stage2/NQPHLL.nqp​:1487
(/home/andreoss/.rakudobrew/moar-nom/install/share/nqp/lib/NQPHLL.moarvm​:evalfiles​:91)
from gen/moar/stage2/NQPHLL.nqp​:1386
(/home/andreoss/.rakudobrew/moar-nom/install/share/nqp/lib/NQPHLL.moarvm​:command_eval​:214)
from src/Perl6/Compiler.nqp​:59
(/home/andreoss/.rakudobrew/moar-nom/install/share/nqp/lib/Perl6/Compiler.moarvm​:command_eval​:93)
from gen/moar/stage2/NQPHLL.nqp​:1360
(/home/andreoss/.rakudobrew/moar-nom/install/share/nqp/lib/NQPHLL.moarvm​:command_line​:116)
from src/gen/m-main.nqp​:39
(/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:MAIN​:18)
from src/gen/m-main.nqp​:35
(/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:<mainline>​:197)
from <unknown>​:1
(/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:<main>​:8)
from <unknown>​:1
(/home/andreoss/.rakudobrew/moar-nom/install/share/perl6/runtime/perl6.moarvm​:<entry>​:9)
$1 = void

@p6rt
Copy link
Author

p6rt commented Jun 9, 2015

From @stmuk

using perl6-valgrind-m

==28463==
==28463== Invalid read of size 8
==28463== at 0x4FD0809​: MVM_6model_find_method_cache_only (6model.c​:26)
==28463== by 0x7CFDA68​: rakudo_scalar_store (container.c​:133)
==28463== by 0x4F79AAE​: MVM_interp_run (interp.c​:1225)
==28463== by 0x501C5CD​: MVM_vm_run_file (moar.c​:218)
==28463== by 0x400FDE​: main (main.c​:189)
==28463== Address 0x10 is not stack'd, malloc'd or (recently) free'd
==28463==
==28463==
==28463== Process terminating with default action of signal 11 (SIGSEGV)​: dumping core
==28463== Access not within mapped region at address 0x10
==28463== at 0x4FD0809​: MVM_6model_find_method_cache_only (6model.c​:26)
==28463== by 0x7CFDA68​: rakudo_scalar_store (container.c​:133)
==28463== by 0x4F79AAE​: MVM_interp_run (interp.c​:1225)
==28463== by 0x501C5CD​: MVM_vm_run_file (moar.c​:218)
==28463== by 0x400FDE​: main (main.c​:189)
==28463== If you believe this happened as a result of a stack
==28463== overflow in your program's main thread (unlikely but
==28463== possible), you can try to increase the size of the
==28463== main thread stack using the --main-stacksize= flag.
==28463== The main thread stack size used in this run was 8388608.
==28463==
==28463== HEAP SUMMARY​:
==28463== in use at exit​: 51,040,924 bytes in 175,681 blocks
==28463== total heap usage​: 262,560 allocs, 86,879 frees, 98,905,618 bytes allocated
==28463==
==28463== LEAK SUMMARY​:
==28463== definitely lost​: 57,511 bytes in 1,234 blocks
==28463== indirectly lost​: 24,786 bytes in 1,085 blocks
==28463== possibly lost​: 171,930 bytes in 3,075 blocks
==28463== still reachable​: 50,786,697 bytes in 170,287 blocks
==28463== suppressed​: 0 bytes in 0 blocks
==28463== Rerun with --leak-check=full to see details of leaked memory
==28463==
==28463== For counts of detected and suppressed errors, rerun with​: -v
==28463== ERROR SUMMARY​: 1 errors from 1 contexts (suppressed​: 0 from 0)
Segmentation fault (core dumped)

@p6rt
Copy link
Author

p6rt commented Jun 9, 2015

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

@p6rt
Copy link
Author

p6rt commented Jun 29, 2015

From @jnthn

Working on this, but it golfs further to this module​:

subset File of Str;
my File $in = "README.md";
say "OKAY";

And then just pre-compiling it and doing​:

use Dummy;

@p6rt
Copy link
Author

p6rt commented Jun 29, 2015

From @jnthn

On Mon Jun 29 07​:52​:32 2015, jnthn@​jnthn.net wrote​:

Working on this, but it golfs further to this module​:

subset File of Str;
my File $in = "README.md";
say "OKAY";

And then just pre-compiling it and doing​:

use Dummy;

And now fixed, and this golfed version added as a test in S10-packages/precompilation.t.

@p6rt
Copy link
Author

p6rt commented Jun 29, 2015

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

@p6rt p6rt closed this as completed Jun 29, 2015
@p6rt p6rt added the Bug label Jan 5, 2020
@usev6
Copy link

usev6 commented Dec 13, 2020

For the record (and re-using this ticket since it is linked from roast): On the JVM backend the test in S10-packages/precompilation started to fail after timo/rakudo@1acc4d3258.

$ ./rakudo-j -e 'use lib "t/spec/packages/RT125245/lib"; my $comp-unit = $*REPO.need(CompUnit::DependencySpecification.new(:short-name<RT125245>)); say $comp-unit.precompiled'
Type check failed in assignment to $in; expected File but got Str ("/path/t/o...)
  in block <unit> at /path/to/rakudo.jvm/t/spec/packages/RT125245/lib/RT125245.pm6 (RT125245) line 2
  in any  at /path/to/rakudo.jvm/t/spec/packages/RT125245/lib/RT125245.pm6 (RT125245) line 1
  in block <unit> at -e line 1

I've fudged the test with Raku/roast@44685318d2 (for the JVM backend).

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

No branches or pull requests

2 participants