Skip to content

FFI crashes when callback is not the last parameter #817

lyro opened this Issue Apr 12, 2011 · 1 comment

2 participants

lyro commented Apr 12, 2011

When passing a callback to an ffi-bound function and this callback is not the last parameter, rubinius crashs when passing the callback, even if the callback itself is never called. Example:

The C-code:

/* mytest.c */
typedef void (*callback)();
void function(callback cb, int x) { }

and the ruby-code:

# test.rb
require 'ffi'

module Lib
    extend FFI::Library
    ffi_lib "./"

    callback :test_callback, [], :void
    attach_function :function, [:test_callback, :int], :void

p ={}
Lib::function(p, 42)

And rubinius crashes:

% ruby test.rb

Rubinius Crash Report #rbxcrashreport

Error: signal SIGSEGV


Note that everything works fine if the second parameter int x is dropped

Rubinius member

This should have been fixed by @jeremyz

@dbussink dbussink closed this Apr 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.