Skip to content

Instantly share code, notes, and snippets.

@peschwa
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peschwa/863b4d839e0024388052 to your computer and use it in GitHub Desktop.
Save peschwa/863b4d839e0024388052 to your computer and use it in GitHub Desktop.
# git clone https://github.com/rakudo/rakudo
# perl Configure.pl --gen-nqp --gen-moar --backends=moar
# make -j2 && make install
$ ./perl6 --version
This is perl6 version 2014.05-208-g354c5c5 built on MoarVM version 2014.05-124-g462402b
$ ./perl6 -e'my $f = 5; $f.isa(Scalar)'
Segmentation fault
(gdb) s
MVM_multi_cache_add (tc=0x804b340, cache_obj=0xb76bdf00, capture=0xb76bdaec, result=0x99ecb80) at src/6model/reprs/MVMMultiCache.c:155
155 arg = r.o;
(gdb) p *r
Attempt to take contents of a non-pointer value.
(gdb) p r.o
$32 = (MVMObject *) 0xffff0017
(gdb) p *r.o
Cannot access memory at address 0xffff0017
(gdb) l
150 MVMContainerSpec const *contspec = STABLE(arg)->container_spec;
151 if (contspec) {
152 if (contspec->fetch_never_invokes) {
153 MVMRegister r;
154 contspec->fetch(tc, arg, &r);
155 arg = r.o;
156 }
157 else {
158 return cache_obj;
159 }
# making MVM_multi_cache_add return cache_obj (twice in a row)
# right before the SEGV let's the program finish as expected
# i'm not sure that's actually useful information though
# a few different cases follow
$ perl6 -e'say Scalar'
Segmentation fault
$ perl6 -e'my $f = Scalar; say $f;'
(Scalar)
$ perl6 -e'my $f = Scalar; say $f.^mro;'
Segmentation fault
$ perl6 -e'my $f = Scalar; say $f.^mro[1,2];'
(Any) (Mu)
$ perl6 -e'my $f = Scalar; say $f.^mro[0].^name;'
Scalar
$ perl6 -e'my $f = Scalar; say $f.^mro[0]'
Segmentation fault
$ uname -a
Linux debvm 3.2.0-4-686-pae #1 SMP Debian 3.2.57-3+deb7u2 i686 GNU/Linux
# on the other hand:
$ uname -a
Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3 x86_64 GNU/Linux
$ ./perl6 --version
This is perl6 version 2014.05-220-g61eaba6 built on MoarVM version 2014.05-124-g462402b
$ ./perl6 -e'say Scalar'
(Scalar)
$ perl6 -e 'say Scalar'
ASAN:SIGSEGV
=================================================================
==10167==ERROR: AddressSanitizer: SEGV on unknown address 0xffff0023 (pc 0xb6f4d4c2 sp 0xbf7e7b20 bp 0xbf7e8438 T0)
AddressSanitizer can not provide additional info.
#0 0xb6f4d4c1 (/home/psch/rakudo/install/lib/libmoar.so+0x7e94c1)
#1 0xb692cdef (/home/psch/rakudo/install/lib/libmoar.so+0x1c8def)
#2 0xb72da819 (/home/psch/rakudo/install/lib/libmoar.so+0xb76819)
#3 0x807ba5c (/home/psch/rakudo/install/bin/moar+0x807ba5c)
#4 0xb6570a62 (/lib/i386-linux-gnu/i686/cmov/libc-2.19.so+0x19a62)
#5 0x8079b54 (/home/psch/rakudo/install/bin/moar+0x8079b54)
==10167==ABORTING
$ valgrind --tool=memcheck --read-var-info=yes /home/psch/rakudo/install/bin/moar --execname="$0" --libpath="/home/psch/rakudo/install/languages/nqp/lib" --libpath="/home/psch/rakudo/install/languages/perl6/lib" --libpath="/home/psch/rakudo/install/languages/perl6/runtime" /home/psch/rakudo/install/languages/perl6/runtime/perl6.moarvm -e 'say Scalar'
==29063== Memcheck, a memory error detector
==29063== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==29063== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==29063== Command: /home/psch/rakudo/install/bin/moar --execname=/bin/bash --libpath=/home/psch/rakudo/install/languages/nqp/lib --libpath=/home/psch/rakudo/install/languages/perl6/lib --libpath=/home/psch/rakudo/install/languages/perl6/runtime /home/psch/rakudo/install/languages/perl6/runtime/perl6.moarvm -e say\ Scalar
==29063==
==29063== Invalid read of size 4
==29063== at 0x413517C: MVM_multi_cache_add (MVMMultiCache.c:161)
==29063== by 0x40A5955: MVM_interp_run (interp.c:1209)
==29063== by 0x418DE09: MVM_vm_run_file (moar.c:173)
==29063== by 0x8048B50: main (main.c:163)
==29063== Address 0xffff0023 is not stack'd, malloc'd or (recently) free'd
==29063==
==29063==
==29063== Process terminating with default action of signal 11 (SIGSEGV)
==29063== Access not within mapped region at address 0xFFFF0023
==29063== at 0x413517C: MVM_multi_cache_add (MVMMultiCache.c:161)
==29063== by 0x40A5955: MVM_interp_run (interp.c:1209)
==29063== by 0x418DE09: MVM_vm_run_file (moar.c:173)
==29063== by 0x8048B50: main (main.c:163)
==29063== If you believe this happened as a result of a stack
==29063== overflow in your program's main thread (unlikely but
==29063== possible), you can try to increase the size of the
==29063== main thread stack using the --main-stacksize= flag.
==29063== The main thread stack size used in this run was 8388608.
==29063==
==29063== HEAP SUMMARY:
==29063== in use at exit: 88,890,996 bytes in 480,017 blocks
==29063== total heap usage: 516,791 allocs, 36,774 frees, 117,142,858 bytes allocated
==29063==
==29063== LEAK SUMMARY:
==29063== definitely lost: 379,297 bytes in 10,697 blocks
==29063== indirectly lost: 751 bytes in 60 blocks
==29063== possibly lost: 64 bytes in 1 blocks
==29063== still reachable: 88,510,884 bytes in 469,259 blocks
==29063== suppressed: 0 bytes in 0 blocks
==29063== Rerun with --leak-check=full to see details of leaked memory
==29063==
==29063== For counts of detected and suppressed errors, rerun with: -v
==29063== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 25 from 10)
Segmentation fault
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment