Subject:
[ruby-ffi] A really simple example: Segmentation fault
From:
Jesús GS <blaxter@gmail.com>
Date:
1/31/10 1:39 PM
To:
ruby-ffi

In a karmic machine, I've tried this really simple example, but with
ruby fails though running it with jruby 1.4 works as expected.

$ more example.rb
require 'rubygems'
require 'ffi'
extend FFI::Library
ffi_lib './libsample.so'
attach_function :foo, :foo, [:int], :int

$ more foo.c
int foo(int a){ return a*2; }

$ gcc -c foo.c
$ gcc -shared -o libsample.so foo.o
$ ruby example.rb
/usr/lib/ruby/gems/1.8/gems/ffi-0.5.4/lib/ffi/library.rb:93: [BUG]
Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]

Canceled
$ jruby example.rb
4