Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a very unlikely GC bug when using a callback block
This could happen, when the Proc object created by rb_block_proc() is GC'ed before the call is executed. Practically this is very unlikely unless called with GC.stress=true . It can easily be fixed, by returning the Proc object and keeping it in a local variable while the call is executed. When running the test suite with GC.stress=true then it failed like so: Failures: 1) Callback struct by value parameter Failure/Error: LibTest.testCallbackTrV(s) do |struct| s2[:s8] = struct[:s8] s2[:f32] = struct[:f32] s2[:s32] = struct[:s32] end NoMethodError: undefined method `call' for an instance of FFI::MemoryPointer ./spec/ffi/callback_spec.rb:312:in `testCallbackTrV' ./spec/ffi/callback_spec.rb:312:in `block (2 levels) in <module:CallbackSpecs>' 2) Callback with struct by reference argument Failure/Error: LibTest.testCallbackYrV(magic) { |i| v = i } NoMethodError: undefined method `call' for an instance of FFI::Pointer ./spec/ffi/callback_spec.rb:802:in `testCallbackYrV' ./spec/ffi/callback_spec.rb:802:in `block (2 levels) in <module:CallbackWithSpecs>' 3) Callback with struct by reference argument with nil value Failure/Error: LibTest.testCallbackYrV(nil) { |i| v = i } NoMethodError: undefined method `call' for an instance of CallbackWithSpecs::LibTest::S8F32S32 ./spec/ffi/callback_spec.rb:809:in `testCallbackYrV' ./spec/ffi/callback_spec.rb:809:in `block (2 levels) in <module:CallbackWithSpecs>' Finished in 100 minutes 21 seconds (files took 0.56651 seconds to load) 5014 examples, 3 failures
- Loading branch information