Skip to content

Instantly share code, notes, and snippets.

Created March 31, 2016 19:49
Show Gist options
  • Save anonymous/d0d539c1249e073a3b4b427c789fa7d5 to your computer and use it in GitHub Desktop.
Save anonymous/d0d539c1249e073a3b4b427c789fa7d5 to your computer and use it in GitHub Desktop.
///---------Ruby code (./e.rb) -------------
def e(opts)
puts opts['e']
end
///---------C code-------------
#include <ruby.h>
int main(){
VALUE obj;
VALUE result;
VALUE map;
ruby_init();
rb_require("e.rb");
map = rb_hash_new();
rb_hash_aset(map, rb_str_new2("e"),rb_str_new2("val"));
result = rb_funcall(obj, rb_intern("e"), 1, map);
return 0;
}
//-------------Segfault-------------
<main>: [BUG] Segmentation fault at 0x00000000000018
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0001 p:0000 s:0002 E:0013c8 TOP [FINISH]
-- C level backtrace information -------------------------------------------
./e() [0x581c5c] vm_dump.c:690
./e() [0x5f4923] error.c:312
./e(rb_bug+0xb3) [0x5f5b03] error.c:339
./e() [0x4f6d13] signal.c:824
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7f6541d54340] ../nptl/sysdeps/pthread/funlockfile.c:29
./e() [0x419513] eval_intern.h:157
./e() [0x419f76] eval.c:561
./e() [0x41cac4] eval.c:572
./e() [0x5f5fea] error.c:1875
./e() [0x5f7eee] error.c:2073
./e(rb_require_safe+0x7f6) [0x4205d6] load.c:934
./e(main+0x18) [0x418b05]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f65419a0ec5] libc-start.c:287
./e() [0x418a23] enumerator.c:181
-- Other runtime information -----------------------------------------------
Segmentation fault (core dumped)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment