ffi/ffi — Issue #179: Callback with int and a double - Windows
Author: mphi
Created: 2011-11-15 19:08:51+00:00
State: open

I am using Ruby 1.9.2 with FFI 1.0.11

I have a C callback function:
void callback_func(int var1, double var2);
int do_work( void *completion_callback);

And the following Ruby code:
callback :do_work_callback, [:int, :double], :int
attach_function :do_work, [:do_work_callback], :int

So, my program runs the callback with:
LibWrap.do_work do |var1, var2|
puts "Running"
end

When the callback triggers, it works perfectly on Mac, and Linux, but produces the following exception on Windows XP:
Unhandled exception at 0x1000a93a in ruby.exe: 0xC0000005: Access violation reading location 0x0c8206ac.

Here is a screenshot:
http://i44.tinypic.com/14m5j0g.jpg

If my callback_func were any of the following and I adjusted the rest of the code in a similar fashion, then the callback would trigger perfectly, even on Windows XP.
void callback_func(int var1, int var2);
void callback_func(double var1, double var2, double var3);

I find it strange that void callback_func(int var1, double var2) would produce a different outcome.