rubinius/rubinius — Issue #1595: libFFI segfault with single callback parameter x86_64 Intel linux
Author: jeremyz
Created: 2012-03-06 21:23:50+00:00
State: open

cb.c :
``` C
#include
typedef void(*CB)();
static CB cb0_ = 0;
void reg_cb (CB cb0) {
fprintf(stderr,"MYLIB : register callback 0x%X (void)\n",cb0);
cb0_ = cb0;
}
void call_cb () {
fprintf(stderr,"MYLIB : call callback 0x%X\n",cb0_);
cb0_();
}
```

ffi_test.rb :
```ruby
module Native
extend FFI::Library
ffi_lib 'libcb.so'
callback :my_cb, [ :int ], :void
attach_function :reg_cb, [ :my_cb ], :void
attach_function :call_cb, [ ], :void
end
cb0 = Proc.new { puts "hello world" }
Native.reg_cb cb0
Native.call_cb
```

rubinius HEAD : 47d32358d133915ca540abd55abf8cde9e6581fe
./configure --skip-system && rake build && LD_LIBRARY_PATH=./ffi_test ./bin/rbx ffi_test/ffi_test.rb

MYLIB : register callback 0x242D7C0 (void)
MYLIB : call callback 0x242D7C0

---------------------------------------------
CRASH: A fatal error has occurred.

Backtrace:
./bin/rbx[0x5b114c]
/lib/libc.so.6(+0x349f0)[0x7f8c1dc369f0]
[0x242d7c0]
Wrote full error report to: /home/jeyzu/.rubinius_last_error
Run 'rbx report' to submit this crash report!

replace vendor/ libff/.libs/ 5.0.9 with 5.0.10
MYLIB : register callback 0x9AD2F8D0 (void)
MYLIB : call callback 0x9AD2F8D0
hello world