Skip to content

Instantly share code, notes, and snippets.

@emil-perhinschi
Created June 26, 2014 21:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emil-perhinschi/5ad12510fa05af7f7439 to your computer and use it in GitHub Desktop.
Save emil-perhinschi/5ad12510fa05af7f7439 to your computer and use it in GitHub Desktop.
perl6 native call libgsl segmentation fault
emilper@main:~/bin/nqp$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
cloned moarvm, nqp and rakudo this evening
MoarVM:
perl Configure.pl --prefix=/home/emilper/safedelete/ --debug=3 --optimize=0
NQP:
perl Configure.pl --backends=moar --prefix=/home/emilper/safedelete/
Rakudo:
perl Configure.pl --prefix=/home/emilper/safedelete/ --backends=moar
emilper@main:~/testing_ground/perl6$ perl6 --target=mbc --output=native_call.moarvm native_call.p6
emilper@main:~/testing_ground/perl6$ which moar
/home/emilper/safedelete/bin/moar
emilper@main:~/testing_ground/perl6$ gdb /home/emilper/safedelete/bin/moar
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 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 /home/emilper/safedelete/bin/moar...done.
(gdb) run --libpath=/home/emilper/safedelete/languages/nqp/lib/ --libpath=/home/emilper/safedelete/languages/perl6/runtime --libpath=/home/emilper/safedelete/languages/nqp/lib/ /home/emilper/testing_ground/perl6/native_call.moarvm
Starting program: /home/emilper/safedelete/bin/moar --libpath=/home/emilper/safedelete/languages/nqp/lib/ --libpath=/home/emilper/safedelete/languages/perl6/runtime --libpath=/home/emilper/safedelete/languages/nqp/lib/ /home/emilper/testing_ground/perl6/native_call.moarvm
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff79b4b5e in deserialize_stable (tc=0x6035e0, reader=0x1853470, i=0, st=0x17dadb0) at src/6model/serialization.c:1939
1939 cc->set_container_spec(tc, st);
(gdb) bt full
#0 0x00007ffff79b4b5e in deserialize_stable (tc=0x6035e0, reader=0x1853470, i=0, st=0x17dadb0) at src/6model/serialization.c:1939
cc = 0x0
st_table_row = 0x7ffff505053a "\001"
#1 0x00007ffff79b56f4 in MVM_serialization_deserialize (tc=0x6035e0, sc=0x7ffff6366ab0, string_heap=0x7ffff6366be8, codes_static=0x7ffff6366c20, repo_conflicts=0x7ffff6366bb0, data=0x0) at src/6model/serialization.c:2137
scodes = 84
i = 9
reader = 0x1853470
#2 0x00007ffff79257ee in MVM_interp_run (tc=0x6035e0, initial_invoke=0x7ffff79e50c6 <toplevel_initial_invoke>, invoke_data=0x683b78) at src/core/interp.c:3538
sc = 0x7ffff6366ab0
conf = 0x7ffff6366bb0
blob = 0x0
sh = 0x7ffff6366be8
cr = 0x7ffff6366c20
op = 405
LABELS = {0x7ffff7909c68 <MVM_interp_run+210>, 0x7ffff790b2ac <MVM_interp_run+5910>, 0x7ffff790b2ae <MVM_interp_run+5912>, 0x7ffff790b2ae <MVM_interp_run+5912>, 0x7ffff790b2c9 <MVM_interp_run+5939>,
0x7ffff790b352 <MVM_interp_run+6076>, 0x7ffff790b36d <MVM_interp_run+6103>, 0x7ffff790b405 <MVM_interp_run+6255>, 0x7ffff790a61b <MVM_interp_run+2693>, 0x7ffff790a5e8 <MVM_interp_run+2642>, 0x7ffff790a5ea <MVM_interp_run+2644>,
0x7ffff790a5ec <MVM_interp_run+2646>, 0x7ffff790a5ee <MVM_interp_run+2648>, 0x7ffff790a5f0 <MVM_interp_run+2650>, 0x7ffff790a5f2 <MVM_interp_run+2652>, 0x7ffff790a5f4 <MVM_interp_run+2654>, 0x7ffff790a5f6 <MVM_interp_run+2656>,
0x7ffff790a5f8 <MVM_interp_run+2658>, 0x7ffff790a5fa <MVM_interp_run+2660>, 0x7ffff790a5fc <MVM_interp_run+2662>, 0x7ffff790a5fe <MVM_interp_run+2664>, 0x7ffff790a600 <MVM_interp_run+2666>, 0x7ffff790a600 <MVM_interp_run+2666>,
0x7ffff7909caa <MVM_interp_run+276>, 0x7ffff7909d26 <MVM_interp_run+400>, 0x7ffff7909de0 <MVM_interp_run+586>, 0x7ffff7909e9a <MVM_interp_run+772>, 0x7ffff7909f64 <MVM_interp_run+974>, 0x7ffff790a02e <MVM_interp_run+1176>,
0x7ffff790a16c <MVM_interp_run+1494>, 0x7ffff790a2aa <MVM_interp_run+1812>, 0x7ffff790a384 <MVM_interp_run+2030>, 0x7ffff790a45e <MVM_interp_run+2248>, 0x7ffff790a523 <MVM_interp_run+2445>,
0x7ffff790ef46 <MVM_interp_run+21424>, 0x7ffff790a6b1 <MVM_interp_run+2843>, 0x7ffff790a8a4 <MVM_interp_run+3342>, 0x7ffff790a9b6 <MVM_interp_run+3616>, 0x7ffff790aa69 <MVM_interp_run+3795>,
0x7ffff790ab1c <MVM_interp_run+3974>, 0x7ffff790abcf <MVM_interp_run+4153>, 0x7ffff790aca0 <MVM_interp_run+4362>, 0x7ffff790ad52 <MVM_interp_run+4540>, 0x7ffff790ae07 <MVM_interp_run+4721>, 0x7ffff790aeb9 <MVM_interp_run+4899>,
0x7ffff790afcc <MVM_interp_run+5174>, 0x7ffff790afcc <MVM_interp_run+5174>, 0x7ffff790f175 <MVM_interp_run+21983>, 0x7ffff790f22d <MVM_interp_run+22167>, 0x7ffff790fbb6 <MVM_interp_run+24608>,
0x7ffff7912c2a <MVM_interp_run+37012>, 0x7ffff790afe7 <MVM_interp_run+5201>, 0x7ffff790b079 <MVM_interp_run+5347>, 0x7ffff790b117 <MVM_interp_run+5505>, 0x7ffff790b1a9 <MVM_interp_run+5651>,
0x7ffff790b23b <MVM_interp_run+5797>, 0x7ffff790cda4 <MVM_interp_run+12814>, 0x7ffff790ce65 <MVM_interp_run+13007>, 0x7ffff790cf26 <MVM_interp_run+13200>, 0x7ffff790cfe7 <MVM_interp_run+13393>,
0x7ffff790d0a8 <MVM_interp_run+13586>, 0x7ffff790d169 <MVM_interp_run+13779>, 0x7ffff790f92b <MVM_interp_run+23957>, 0x7ffff790b49d <MVM_interp_run+6407>, 0x7ffff790b558 <MVM_interp_run+6594>,
0x7ffff790b616 <MVM_interp_run+6784>, 0x7ffff790b6d2 <MVM_interp_run+6972>, 0x7ffff790b85a <MVM_interp_run+7364>, 0x7ffff790b91b <MVM_interp_run+7557>, 0x7ffff790b9dc <MVM_interp_run+7750>, 0x7ffff790baa0 <MVM_interp_run+7946>,
0x7ffff790bb39 <MVM_interp_run+8099>, 0x7ffff790bc00 <MVM_interp_run+8298>, 0x7ffff790bc7b <MVM_interp_run+8421>, 0x7ffff790bcf6 <MVM_interp_run+8544>, 0x7ffff790bd71 <MVM_interp_run+8667>,
0x7ffff790e7a5 <MVM_interp_run+19471>, 0x7ffff790e860 <MVM_interp_run+19658>, 0x7ffff790e91b <MVM_interp_run+19845>, 0x7ffff790e9d6 <MVM_interp_run+20032>, 0x7ffff790ea6f <MVM_interp_run+20185>,
0x7ffff790eb2f <MVM_interp_run+20377>, 0x7ffff790ebef <MVM_interp_run+20569>, 0x7ffff790fb17 <MVM_interp_run+24449>, 0x7ffff7917075 <MVM_interp_run+54495>, 0x7ffff791718f <MVM_interp_run+54777>,
0x7ffff790d22a <MVM_interp_run+13972>, 0x7ffff790d2fa <MVM_interp_run+14180>, 0x7ffff790d3ca <MVM_interp_run+14388>, 0x7ffff790d48e <MVM_interp_run+14584>, 0x7ffff790d552 <MVM_interp_run+14780>,
0x7ffff790d616 <MVM_interp_run+14976>, 0x7ffff790fa1f <MVM_interp_run+24201>, 0x7ffff790c812 <MVM_interp_run+11388>, 0x7ffff790c8d1 <MVM_interp_run+11579>, 0x7ffff790c990 <MVM_interp_run+11770>,
0x7ffff790ca4f <MVM_interp_run+11961>, 0x7ffff790cb0e <MVM_interp_run+12152>, 0x7ffff790cc32 <MVM_interp_run+12444>, 0x7ffff790ccd6 <MVM_interp_run+12608>, 0x7ffff790ed2c <MVM_interp_run+20886>,
0x7ffff7912d62 <MVM_interp_run+37324>, 0x7ffff7912e50 <MVM_interp_run+37562>, 0x7ffff7916616 <MVM_interp_run+51840>, 0x7ffff79166d0 <MVM_interp_run+52026>, 0x7ffff791678a <MVM_interp_run+52212>,
0x7ffff7916844 <MVM_interp_run+52398>, 0x7ffff79168fe <MVM_interp_run+52584>, 0x7ffff79169b8 <MVM_interp_run+52770>, 0x7ffff7916a72 <MVM_interp_run+52956>, 0x7ffff7916b5d <MVM_interp_run+53191>,
0x7ffff7916c19 <MVM_interp_run+53379>, 0x7ffff7916cd1 <MVM_interp_run+53563>, 0x7ffff7916d8b <MVM_interp_run+53749>, 0x7ffff7916e45 <MVM_interp_run+53935>, 0x7ffff7916eff <MVM_interp_run+54121>,
0x7ffff7916fbb <MVM_interp_run+54309>, 0x7ffff791960b <MVM_interp_run+64117>, 0x7ffff79196c5 <MVM_interp_run+64303>, 0x7ffff790e66d <MVM_interp_run+19159>, 0x7ffff790e709 <MVM_interp_run+19315>,
0x7ffff790f2e1 <MVM_interp_run+22347>, 0x7ffff790f38a <MVM_interp_run+22516>, 0x7ffff790f43f <MVM_interp_run+22697>, 0x7ffff790f4e8 <MVM_interp_run+22866>, 0x7ffff790f5a0 <MVM_interp_run+23050>,
0x7ffff790f661 <MVM_interp_run+23243>, 0x7ffff790be86 <MVM_interp_run+8944>, 0x7ffff790bf4d <MVM_interp_run+9143>, 0x7ffff790bfeb <MVM_interp_run+9301>, 0x7ffff790c089 <MVM_interp_run+9459>,
0x7ffff790c127 <MVM_interp_run+9617>, 0x7ffff790d6da <MVM_interp_run+15172>, 0x7ffff790d76b <MVM_interp_run+15317>, 0x7ffff790d80b <MVM_interp_run+15477>, 0x7ffff790c1c5 <MVM_interp_run+9775>,
0x7ffff790c2f2 <MVM_interp_run+10076>, 0x7ffff790c43a <MVM_interp_run+10404>, 0x7ffff790c582 <MVM_interp_run+10732>, 0x7ffff790c6ca <MVM_interp_run+11060>, 0x7ffff790d8ab <MVM_interp_run+15637>,
0x7ffff790d93d <MVM_interp_run+15783>, 0x7ffff790d9e6 <MVM_interp_run+15952>, 0x7ffff790da8f <MVM_interp_run+16121>, 0x7ffff790db38 <MVM_interp_run+16290>, 0x7ffff790dbe1 <MVM_interp_run+16459>,
0x7ffff790dccb <MVM_interp_run+16693>, 0x7ffff790ddb5 <MVM_interp_run+16927>, 0x7ffff790de9f <MVM_interp_run+17161>, 0x7ffff790df89 <MVM_interp_run+17395>, 0x7ffff790e045 <MVM_interp_run+17583>,
0x7ffff790e101 <MVM_interp_run+17771>, 0x7ffff790e1bd <MVM_interp_run+17959>, 0x7ffff790e279 <MVM_interp_run+18147>, 0x7ffff790e376 <MVM_interp_run+18400>, 0x7ffff790e473 <MVM_interp_run+18653>,
0x7ffff790e570 <MVM_interp_run+18906>, 0x7ffff790f722 <MVM_interp_run+23436>, 0x7ffff790f7c9 <MVM_interp_run+23603>, 0x7ffff790bdec <MVM_interp_run+8790>, 0x7ffff790f075 <MVM_interp_run+21727>,
0x7ffff790ee17 <MVM_interp_run+21121>, 0x7ffff790ee9d <MVM_interp_run+21255>, 0x7ffff7910fa5 <MVM_interp_run+29711>, 0x7ffff791103f <MVM_interp_run+29865>, 0x7ffff7911168 <MVM_interp_run+30162>,
0x7ffff7911291 <MVM_interp_run+30459>, 0x7ffff791138c <MVM_interp_run+30710>, 0x7ffff7911482 <MVM_interp_run+30956>, 0x7ffff7911578 <MVM_interp_run+31202>, 0x7ffff7911673 <MVM_interp_run+31453>,
0x7ffff7911736 <MVM_interp_run+31648>, 0x7ffff79117f9 <MVM_interp_run+31843>, 0x7ffff79118bc <MVM_interp_run+32038>, 0x7ffff791196f <MVM_interp_run+32217>, 0x7ffff7911a22 <MVM_interp_run+32396>,
0x7ffff7911ad5 <MVM_interp_run+32575>, 0x7ffff7925f4b <MVM_interp_run+115637>, 0x7ffff7925fc6 <MVM_interp_run+115760>, 0x7ffff7911c06 <MVM_interp_run+32880>, 0x7ffff7911c94 <MVM_interp_run+33022>,
0x7ffff7911d27 <MVM_interp_run+33169>, 0x7ffff7913259 <MVM_interp_run+38595>, 0x7ffff7911e1d <MVM_interp_run+33415>, 0x7ffff7911eaf <MVM_interp_run+33561>, 0x7ffff7912055 <MVM_interp_run+33983>,
0x7ffff7912165 <MVM_interp_run+34255>, 0x7ffff79122a7 <MVM_interp_run+34577>, 0x7ffff79123e9 <MVM_interp_run+34899>, 0x7ffff791252b <MVM_interp_run+35221>, 0x7ffff791266d <MVM_interp_run+35543>,
0x7ffff7926da0 <MVM_interp_run+119306>, 0x7ffff7926ede <MVM_interp_run+119624>, 0x7ffff79128b4 <MVM_interp_run+36126>, 0x7ffff7912a75 <MVM_interp_run+36575>, 0x7ffff7912b5f <MVM_interp_run+36809>,
0x7ffff791f003 <MVM_interp_run+87149>, 0x7ffff791e9a4 <MVM_interp_run+85518>, 0x7ffff7913d8a <MVM_interp_run+41460>, 0x7ffff7913e55 <MVM_interp_run+41663>...}
cur_op = 0x7ffff507266e "\016"
bytecode_start = 0x7ffff50714e2 "\237"
reg_base = 0x7ffff500e010
cu = 0x7ffff6357890
cur_callsite = 0x698810
---Type <return> to continue, or q <return> to quit---
#3 0x00007ffff79e51ae in MVM_vm_run_file (instance=0x603010, filename=0x7fffffffe13e "/home/emilper/testing_ground/perl6/native_call.moarvm") at src/moar.c:158
str = 0x7ffff62f67c8
start_frame = 0x7ffff7ffe1c8
tc = 0x6035e0
cu = 0x7ffff62f66e8
#4 0x0000000000400ef7 in main (argc=5, argv=0x7fffffffdcc8) at src/main.c:163
instance = 0x603010
input_file = 0x7fffffffe13e "/home/emilper/testing_ground/perl6/native_call.moarvm"
executable_name = 0x0
lib_path = {0x7fffffffe0a1 "/home/emilper/safedelete/languages/nqp/lib/", 0x7fffffffe0d7 "/home/emilper/safedelete/languages/perl6/runtime", 0x7fffffffe112 "/home/emilper/safedelete/languages/nqp/lib/", 0x0,
0x400f20 <__libc_csu_init> "AWA\211\377AVI\211\366AUI\211\325ATL\215%h\016 ", 0x4009f0 <_start> "1\355I\211\321^H\211\342H\203\344\360PTI\307\300\220\017@", 0x7fffffffdcc0 "\005", 0x0}
dump = 0
full_cleanup = 0
argi = 3
lib_path_i = 3
flag = -2
(gdb)
use NativeCall;
sub cblas_dasum(Int $i, Num $j, Int $x) returns Num is native('libgslcblas') {*}
sub ceil(Num $x) returns Num is native('libm') {*}
sub gsl_rng_default()
returns OpaquePointer
is native('libgsl') {*}
sub gsl_rng_alloc(OpaquePointer $type )
returns OpaquePointer
is native('libgsl') {*}
sub gsl_rng_uniform(OpaquePointer $rng_handler)
returns Num
is native('libgsl') {*}
my Num $double = 3e0;
my Int $int1 = 1;
my Int $int2 = 2;
my Num $x = cblas_dasum($int1,$double,$int2);
say 'cblas_dasum ran, returned', $x;
say ceil(3e0);
say 'after ceil';
my OpaquePointer $rng_type = gsl_rng_default();
say 'gsl_rng_default ran';
my OpaquePointer $rng_handle = gsl_rng_alloc($rng_type);
say 'gsl_rng_alloc ran';
say gsl_rng_uniform($rng_handle);
say 'gsl_rng_uniform ran';
@bdw
Copy link

bdw commented Jun 26, 2014

Basically, it crashes because it's looking for a container configuration (cc) by a string in the container registry, which doesn't exist, and hence the container configuration returned is NULL. See src/6model/serialization.c

What that string is, I'd like to know. If you want to figure it out, set a conditional breakpoint on line 2137 of src/6model/serialization.c when i = 9, and then step until line 1937 of the same file (or break there).

I don't think I have libgslcblas installed, otherwise I could try to run it myself :-)

@bdw
Copy link

bdw commented Jun 26, 2014

See http://blog.vinceliu.com/2009/07/gdbs-conditional-breakpoints.html for how to set conditional breakpoints

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