Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active August 6, 2019 18:20
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 dogbert17/1de3deeb2c11ec03fa8e33b8389558dd to your computer and use it in GitHub Desktop.
Save dogbert17/1de3deeb2c11ec03fa8e33b8389558dd to your computer and use it in GitHub Desktop.
Heap profiler sometimes fail
dogbert@dogbert-VirtualBox ~/repos/rakudo $ cat ~/euler-3.pl6
# What is the largest prime factor of the number 600851475143 ?
use v6;
my $num = 600_851_475_143;
my $val = $num;
my @factors = ();
while ([*] @factors) != $num {
push @factors, (2...*).first(-> $x { $val %% $x && $x.is-prime });
$val = $val div @factors[*-1];
}
say @factors.max; # remove max to see all prime factors
dogbert@dogbert-VirtualBox ~/repos/rakudo $ ./perl6-m --profile --profile-kind=heap ~/euler-3.pl6
Segmentation fault (core dumped)
dogbert@dogbert-VirtualBox ~/repos/rakudo $ gdb install/bin/moar core
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from install/bin/moar...done.
[New LWP 32186]
[New LWP 32187]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/home/dogbert/repos/rakudo/nqp/MoarVM/../../install/bin/moar --execname=/home/d'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007fe32a4d1299 in describe_refs (tc=0x248da70, ss=0x7fffc8fd9f50, st=0x24f94f8, data=0x42db728) at src/6model/reprs/MVMSpeshLog.c:69
69 switch (body->entries[i].kind) {
[Current thread is 1 (Thread 0x7fe32af1d700 (LWP 32186))]
(gdb) bt
#0 0x00007fe32a4d1299 in describe_refs (tc=0x248da70, ss=0x7fffc8fd9f50, st=0x24f94f8, data=0x42db728) at src/6model/reprs/MVMSpeshLog.c:69
#1 0x00007fe32a57a42c in process_object (tc=0x248da70, ss=0x7fffc8fd9f50, col=0x7fffc8fd9ec0, obj=0x42db710) at src/profiler/heapsnapshot.c:338
#2 0x00007fe32a57a5ed in process_workitems (tc=0x248da70, ss=0x7fffc8fd9f50) at src/profiler/heapsnapshot.c:362
#3 0x00007fe32a57b593 in record_snapshot (tc=0x248da70, col=0x5327ad0, hs=0x52357c0) at src/profiler/heapsnapshot.c:635
#4 0x00007fe32a57c5c1 in MVM_profile_heap_take_snapshot (tc=0x248da70) at src/profiler/heapsnapshot.c:936
#5 0x00007fe32a46a534 in finish_gc (tc=0x248da70, gen=0 '\000', is_coordinator=1 '\001') at src/gc/orchestrate.c:260
#6 0x00007fe32a46a9f6 in run_gc (tc=0x248da70, what_to_do=0 '\000') at src/gc/orchestrate.c:420
#7 0x00007fe32a46af0f in MVM_gc_enter_from_allocator (tc=0x248da70) at src/gc/orchestrate.c:552
#8 0x00007fe32a46b78b in MVM_gc_allocate_nursery (tc=0x248da70, size=88) at src/gc/allocation.c:35
#9 0x00007fe32a46b586 in MVM_gc_allocate (tc=0x248da70, size=88) at src/gc/allocation.h:18
#10 0x00007fe32a46b814 in MVM_gc_allocate_zeroed (tc=0x248da70, size=88) at src/gc/allocation.c:52
#11 0x00007fe32a46b9db in MVM_gc_allocate_object (tc=0x248da70, st=0x24f9110) at src/gc/allocation.c:89
#12 0x00007fe32a48c0d6 in MVM_repr_alloc_init (tc=0x248da70, type=0x2504b80) at src/6model/reprconv.c:17
#13 0x00007fe32a453b91 in MVM_continuation_control (tc=0x248da70, protect=0, tag=0x4b54810, code=0x7fe3267322d8, res_reg=0x298d8a8) at src/core/continuation.c:83
#14 0x00007fe32a41931c in MVM_interp_run (tc=0x248da70, initial_invoke=0x7fe32a584dd6 <toplevel_initial_invoke>, invoke_data=0x256bdb8) at src/core/interp.c:3951
#15 0x00007fe32a584f4e in MVM_vm_run_file (instance=0x248d010, filename=0x7fffc8fdc180 "/home/dogbert/repos/rakudo/perl6.moarvm") at src/moar.c:445
#16 0x00000000004016e7 in main (argc=10, argv=0x7fffc8fdbc38) at src/main.c:302
dogbert@dogbert-VirtualBox ~/repos/rakudo $ ./perl6-m --profile --profile-kind=heap ~/euler-3.pl6
ASAN:SIGSEGV
=================================================================
==1150==ERROR: AddressSanitizer: SEGV on unknown address 0x00000003a4e8 (pc 0x7f4bd834f5bf bp 0x7ffd0f37e410 sp 0x7ffd0f37e3e0 T0)
#0 0x7f4bd834f5be in describe_refs src/6model/reprs/MVMSpeshLog.c:69
#1 0x7f4bd84c4538 in process_object src/profiler/heapsnapshot.c:338
#2 0x7f4bd84c4a06 in process_workitems src/profiler/heapsnapshot.c:362
#3 0x7f4bd84c6a71 in record_snapshot src/profiler/heapsnapshot.c:635
#4 0x7f4bd84c93f9 in MVM_profile_heap_take_snapshot src/profiler/heapsnapshot.c:936
#5 0x7f4bd824256a in finish_gc src/gc/orchestrate.c:260
#6 0x7f4bd8242ef6 in run_gc src/gc/orchestrate.c:420
#7 0x7f4bd8243b56 in MVM_gc_enter_from_allocator src/gc/orchestrate.c:552
#8 0x7f4bd8245055 in MVM_gc_allocate_nursery src/gc/allocation.c:35
#9 0x7f4bd82449d6 in MVM_gc_allocate src/gc/allocation.h:18
#10 0x7f4bd8245132 in MVM_gc_allocate_zeroed src/gc/allocation.c:52
#11 0x7f4bd82455bf in MVM_gc_allocate_object src/gc/allocation.c:89
#12 0x7f4bd81c6adb in MVM_frame_takeclosure src/core/frame.c:1207
#13 0x7f4bd8161bd7 in MVM_interp_run src/core/interp.c:1232
#14 0x7f4bd84de93d in MVM_vm_run_file src/moar.c:445
#15 0x40232c in main src/main.c:302
#16 0x7f4bd76c182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#17 0x401298 in _start (/home/dogbert/repos/rakudo/install/bin/moar+0x401298)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV src/6model/reprs/MVMSpeshLog.c:69 describe_refs
==1150==ABORTING
dogbert@dogbert-VirtualBox ~/repos/rakudo $ ./perl6-gdb-m --profile --profile-kind=heap ~/euler-3.pl6
================================================================================================
This is Rakudo Perl 6 running in the debugger, which often allows the user to generate useful back-
traces to debug or report issues in Rakudo, the MoarVM backend or the currently running code.
This Rakudo version is 2019.07.1.116.g.22702.ea built on MoarVM version 2019.07.1.68.g.9.c.969.b.1,
running on linuxmint (18.3.Sylvia) / linux (42.16.04.1.Ubuntu.SMP.Tue.Oct.10.16.32.20.UTC.2017)
Type `bt full` to generate a backtrace if applicable, type `q` to quit or `help` for help.
------------------------------------------------------------------------------------------------
Reading symbols from /home/dogbert/repos/rakudo/nqp/MoarVM/../../install/bin/moar...done.
Starting program: /home/dogbert/repos/rakudo/install/bin/moar --execname=/home/dogbert/repos/rakudo/perl6-gdb-m --libpath=/home/dogbert/repos/rakudo --libpath=/home/dogbert/repos/rakudo/blib --libpath= --libpath=/home/dogbert/repos/rakudo/install/share/nqp/lib /home/dogbert/repos/rakudo/perl6.moarvm --nqp-lib=/home/dogbert/repos/rakudo/blib --profile --profile-kind=heap /home/dogbert/euler-3.pl6
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff61d5700 (LWP 2790)]
Thread 1 "moar" received signal SIGSEGV, Segmentation fault.
0x00007ffff7593299 in describe_refs (tc=0x604a70, ss=0x7fffffffbf30, st=0x6704f8, data=0x2451a48) at src/6model/reprs/MVMSpeshLog.c:69
69 switch (body->entries[i].kind) {
(gdb) p body
$1 = (MVMSpeshLogBody *) 0x2451a48
(gdb) p *body
$2 = {thread = 0x68b420, entries = 0x0, used = 16384, limit = 16384, was_compunit_bumped = 1 '\001', block_mutex = 0x0, block_condvar = 0x0, completed = 0}
(gdb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment