Created
March 27, 2011 16:13
-
-
Save mutle/889333 to your computer and use it in GitHub Desktop.
Rubinius FFI Callback deadlock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) bt | |
#0 0x00007fff8471cf8a in __semwait_signal () | |
#1 0x00007fff84720da1 in _pthread_cond_wait () | |
#2 0x0000000100028632 in rubinius::GlobalLock::take (this=0x101006208) at thread.hpp:405 | |
#3 0x000000010013a35e in rubinius::NativeFunction::call (this=0x101a3ad60, state=0x100f06280, args=@0x7fff5fbfb580, msg=<value temporarily unavailable, due to optimizations>, call_frame=0x7fff5fbfb630) at vm/builtin/nativefunction.cpp:1013 | |
#4 0x000000010013b197 in rubinius::NativeFunction::execute (state=0x100f06280, call_frame=0x7fff5fbfb630, msg=@0x102e5bcf0, args=@0x7fff5fbfb580) at vm/builtin/nativefunction.cpp:86 | |
#5 0x00000001000375a0 in rubinius::VMMethod::interpreter (state=0x100f06280, vmm=0x102ea9960, call_frame=0x7fff5fbfb630) at instruction_implementations.hpp:526 | |
#6 0x0000000100115e1f in rubinius::VMMethod::execute_specialized<rubinius::OneArgument> (state=0x100f06280, previous=0x7fff5fbfba90, msg=@0x10143b500, args=@0x7fff5fbfb9e0) at vm/vmmethod.cpp:615 | |
#7 0x0000000100120cdb in rubinius::CompiledMethod::default_executor (state=0x100f06280, call_frame=0x7fff5fbfba90, msg=@0x10143b500, args=@0x7fff5fbfb9e0) at vm/builtin/compiledmethod.cpp:156 | |
#8 0x00000001000375a0 in rubinius::VMMethod::interpreter (state=0x100f06280, vmm=0x102ac0d10, call_frame=0x7fff5fbfba90) at instruction_implementations.hpp:526 | |
#9 0x0000000100114990 in rubinius::VMMethod::execute_specialized<rubinius::NoArguments> (state=0x100f06280, previous=0x7fff5fbfbfb0, msg=@0x7fff5fbfbc90, args=@0x7fff5fbfbf00) at vm/vmmethod.cpp:615 | |
#10 0x0000000100120cdb in rubinius::CompiledMethod::default_executor (state=0x100f06280, call_frame=0x7fff5fbfbfb0, msg=@0x7fff5fbfbc90, args=@0x7fff5fbfbf00) at vm/builtin/compiledmethod.cpp:156 | |
#11 0x00000001001410b1 in rubinius::Object::send_prim (this=0x101b0ffa8, state=0x100f06280, exec=<value temporarily unavailable, due to optimizations>, call_frame=0x7fff5fbfbfb0, msg=<value temporarily unavailable, due to optimizations>, args=@0x7fff5fbfbf00) at vm/builtin/object.cpp:525 | |
#12 0x00000001000b58fb in rubinius::Primitives::object_send (state=0x100f06280, call_frame=0x7fff5fbfbfb0, msg=@0x102abcf10, args=@0x7fff5fbfbf00) at primitives_glue.gen.cpp:21276 | |
#13 0x00000001000375a0 in rubinius::VMMethod::interpreter (state=0x100f06280, vmm=0x102abc8a0, call_frame=0x7fff5fbfbfb0) at instruction_implementations.hpp:526 | |
#14 0x0000000100115e1f in rubinius::VMMethod::execute_specialized<rubinius::OneArgument> (state=0x100f06280, previous=0x7fff5fbfc410, msg=@0x102abc6f0, args=@0x7fff5fbfc360) at vm/vmmethod.cpp:615 | |
#15 0x0000000100120cdb in rubinius::CompiledMethod::default_executor (state=0x100f06280, call_frame=0x7fff5fbfc410, msg=@0x102abc6f0, args=@0x7fff5fbfc360) at vm/builtin/compiledmethod.cpp:156 | |
#16 0x00000001000375a0 in rubinius::VMMethod::interpreter (state=0x100f06280, vmm=0x102abc180, call_frame=0x7fff5fbfc410) at instruction_implementations.hpp:526 | |
#17 0x0000000100114dfb in rubinius::VMMethod::execute_specialized<rubinius::GenericArguments> (state=0x100f06280, previous=0x7fff5fbfc890, msg=@0x10142ac80, args=@0x7fff5fbfc7e0) at vm/vmmethod.cpp:615 | |
#18 0x0000000100120cdb in rubinius::CompiledMethod::default_executor (state=0x100f06280, call_frame=0x7fff5fbfc890, msg=@0x10142ac80, args=@0x7fff5fbfc7e0) at vm/builtin/compiledmethod.cpp:156 | |
#19 0x00000001000375a0 in rubinius::VMMethod::interpreter (state=0x100f06280, vmm=0x102ab9fc0, call_frame=0x7fff5fbfc890) at instruction_implementations.hpp:526 | |
#20 0x0000000100114990 in rubinius::VMMethod::execute_specialized<rubinius::NoArguments> (state=0x100f06280, previous=0x7fff5fbfcd00, msg=@0x103009e00, args=@0x7fff5fbfcc50) at vm/vmmethod.cpp:615 | |
#21 0x0000000100120cdb in rubinius::CompiledMethod::default_executor (state=0x100f06280, call_frame=0x7fff5fbfcd00, msg=@0x103009e00, args=@0x7fff5fbfcc50) at vm/builtin/compiledmethod.cpp:156 | |
#22 0x0000000100035feb in rubinius::VMMethod::interpreter (state=0x100f06280, vmm=0x102b05d00, call_frame=0x7fff5fbfcd00) at instruction_implementations.hpp:507 | |
#23 0x0000000100114990 in rubinius::VMMethod::execute_specialized<rubinius::NoArguments> (state=0x100f06280, previous=0x7fff5fbfd180, msg=@0x103006600, args=@0x7fff5fbfd0d0) at vm/vmmethod.cpp:615 | |
#24 0x0000000100120cdb in rubinius::CompiledMethod::default_executor (state=0x100f06280, call_frame=0x7fff5fbfd180, msg=@0x103006600, args=@0x7fff5fbfd0d0) at vm/builtin/compiledmethod.cpp:156 | |
#25 0x00000001000375a0 in rubinius::VMMethod::interpreter (state=0x100f06280, vmm=0x102b047a0, call_frame=0x7fff5fbfd180) at instruction_implementations.hpp:526 | |
#26 0x0000000100114990 in rubinius::VMMethod::execute_specialized<rubinius::NoArguments> (state=0x100f06280, previous=0x7fff5fbfd600, msg=@0x102b023b0, args=@0x7fff5fbfd550) at vm/vmmethod.cpp:615 | |
#27 0x0000000100120cdb in rubinius::CompiledMethod::default_executor (state=0x100f06280, call_frame=0x7fff5fbfd600, msg=@0x102b023b0, args=@0x7fff5fbfd550) at vm/builtin/compiledmethod.cpp:156 | |
#28 0x00000001000375a0 in rubinius::VMMethod::interpreter (state=0x100f06280, vmm=0x102b01b90, call_frame=0x7fff5fbfd600) at instruction_implementations.hpp:526 | |
#29 0x0000000100114990 in rubinius::VMMethod::execute_specialized<rubinius::NoArguments> (state=0x100f06280, previous=0x0, msg=@0x7fff5fbfd820, args=@0x7fff5fbfd7f0) at vm/vmmethod.cpp:615 | |
#30 0x0000000100120cdb in rubinius::CompiledMethod::default_executor (state=0x100f06280, call_frame=0x0, msg=@0x7fff5fbfd820, args=@0x7fff5fbfd7f0) at vm/builtin/compiledmethod.cpp:156 | |
#31 0x000000010001ed0f in rubinius::CompiledFile::execute (this=<value temporarily unavailable, due to optimizations>, state=0x100f06280) at vm/compiled_file.cpp:51 | |
#32 0x000000010002211c in rubinius::Environment::run_file (this=0x7fff5fbfdf10, file=@0x7fff5fbfde90) at vm/environment.cpp:451 | |
#33 0x0000000100024e5c in std::string::_M_rep () at /usr/include/c++/4.2.1/bits/basic_string.h:597 | |
#34 0x0000000100024e5c in ~basic_string [inlined] () at vm/environment.cpp:493 | |
#35 ~basic_string [inlined] () at /usr/include/c++/4.2.1/bits/basic_string.h:493 | |
#36 0x0000000100024e5c in rubinius::Environment::run_from_filesystem (this=0x7fff5fbfdf10, root=@0x7fff5fbfe490) at vm/environment.cpp:597 | |
#37 0x00000001001bdb16 in std::string::_M_rep () at /usr/include/c++/4.2.1/bits/basic_string.h:50 | |
#38 0x00000001001bdb16 in ~basic_string [inlined] () at vm/drivers/cli.cpp:493 | |
#39 ~basic_string [inlined] () at /usr/include/c++/4.2.1/bits/basic_string.h:493 | |
#40 0x00000001001bdb16 in main (argc=<value temporarily unavailable, due to optimizations>, argv=<value temporarily unavailable, due to optimizations>) at vm/drivers/cli.cpp:50 | |
(gdb) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ ruby test.rb | |
run with callback | |
callback | |
[now the process just hangs, ^C doesn't work, so I have to manually kill the process] | |
^C^C^C^C^C^CTerminated: signal SIGTERM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile with: gcc -dynamiclib -o test.dylib test.c | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef void (*test_callback) (void); | |
void run_with_callback(test_callback cb) { | |
cb(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
class FFITest | |
extend ::FFI::Library | |
ffi_lib File.expand_path("../test.dylib", __FILE__) | |
callback :cb, [], :void | |
attach_function 'run_with_callback', [:cb], :void | |
def initialize(cb) | |
run_with_callback(cb) | |
end | |
end | |
cb = proc { | |
puts "callback" | |
} | |
puts "run with callback" | |
FFITest.new(cb) | |
puts "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment