Subject:
[ruby-ffi] ruby 1.9.1 crashing when executing callback
From:
Chuck Remes
Date:
5/12/10 2:53 PM
To:
ruby-ffi@googlegroups.com

I'm starting to work with callbacks and have run into a consistent crasher. Take a look at the trace here:

http://gist.github.com/398987

I downloaded the ruby-1.9.1 source and poked through vm_eval.c which contains the vm_call0() function. There is a big switch statement in there that falls through to calling rb_bug(). 

This all occurs *only* when invoking the callback. The stack trace clearly shows it is invoking a block (rb_funcall2) from the FFI library. It crashes regardless of the contents of the block (empty, puts, nil, etc.).

In 1.8.7 it crashes with a LocalJumpError somewhere else.

When I disable the callback, there are no crashes under either MRI.

Under JRuby, everything works fine. The callback is invoked successfully.

I'm wondering if this is failing because the callback may be invoked by another native thread. The library being wrapped by FFI spawns many threads that do various background tasks; one of them is likely the invocation of the cleanup callback that is causing the crash.

Are there any known issues with MRI, FFI and callbacks?

cr