ruby / fiddle

A libffi wrapper for Ruby.
BSD 2-Clause "Simplified" License
163 stars 36 forks source link

fiddle v1.1.3 and above breaks ffi head testsuite #159

Closed mtasaka closed 3 weeks ago

mtasaka commented 3 weeks ago

Using ruby 3.4.0dev (2024-11-07 master 048bb1e176) +PRISM [x86_64-linux] https://github.com/ruby/ruby/commit/048bb1e1763c3ea9208a4049b515c15252f19cf1

Testing with ffi head ( https://github.com/ffi/ffi/commit/c128cede750242fe19945af8bd6c797728489ad5 ), test suite does not pass with fiddle v1.1.3, passes with v1.1.2; like

Failures:

  1) Callback interop from ffi to fiddle
     Failure/Error: func = LibTestFiddle.bind_function(:cbVrV, Fiddle::TYPE_VOID, [], &block)

     TypeError:
       wrong argument type Symbol (expected String)
     # /builddir/build/GIT/fiddle/lib/fiddle/import.rb:319:in 'Fiddle::Function#initialize'
     # /builddir/build/GIT/fiddle/lib/fiddle/import.rb:319:in 'Class#new'
     # /builddir/build/GIT/fiddle/lib/fiddle/import.rb:319:in 'Fiddle::Importer#bind_function'
     # ./spec/ffi/callback_spec.rb:912:in 'block (3 levels) in <module:CallbackInteropSpecs>'
     # ./spec/ffi/callback_spec.rb:879:in 'RSpec::ExampleGroups::CallbackInterop#assert_callback_in_same_thread_called_once'
     # ./spec/ffi/callback_spec.rb:911:in 'block (2 levels) in <module:CallbackInteropSpecs>'

  2) Callback interop from ffi to fiddle with blocking:true
     Failure/Error: func = LibTestFiddle.bind_function(:cbVrV, Fiddle::TYPE_VOID, [], &block)

     TypeError:
       wrong argument type Symbol (expected String)
     # /builddir/build/GIT/fiddle/lib/fiddle/import.rb:319:in 'Fiddle::Function#initialize'
     # /builddir/build/GIT/fiddle/lib/fiddle/import.rb:319:in 'Class#new'
     # /builddir/build/GIT/fiddle/lib/fiddle/import.rb:319:in 'Fiddle::Importer#bind_function'
     # ./spec/ffi/callback_spec.rb:920:in 'block (3 levels) in <module:CallbackInteropSpecs>'
     # ./spec/ffi/callback_spec.rb:879:in 'RSpec::ExampleGroups::CallbackInterop#assert_callback_in_same_thread_called_once'
     # ./spec/ffi/callback_spec.rb:919:in 'block (2 levels) in <module:CallbackInteropSpecs>'

  3) Callback interop from fiddle to fiddle
     Failure/Error: func = LibTestFiddle.bind_function(:cbVrV, Fiddle::TYPE_VOID, [], &block)

     TypeError:
       wrong argument type Symbol (expected String)
     # /builddir/build/GIT/fiddle/lib/fiddle/import.rb:319:in 'Fiddle::Function#initialize'
     # /builddir/build/GIT/fiddle/lib/fiddle/import.rb:319:in 'Class#new'
     # /builddir/build/GIT/fiddle/lib/fiddle/import.rb:319:in 'Fiddle::Importer#bind_function'
     # ./spec/ffi/callback_spec.rb:928:in 'block (3 levels) in <module:CallbackInteropSpecs>'
     # ./spec/ffi/callback_spec.rb:879:in 'RSpec::ExampleGroups::CallbackInterop#assert_callback_in_same_thread_called_once'
     # ./spec/ffi/callback_spec.rb:927:in 'block (2 levels) in <module:CallbackInteropSpecs>'

Finished in 3.88 seconds (files took 1.04 seconds to load)
5015 examples, 3 failures

Failed examples:

rspec ./spec/ffi/callback_spec.rb:909 # Callback interop from ffi to fiddle
rspec ./spec/ffi/callback_spec.rb:917 # Callback interop from ffi to fiddle with blocking:true
rspec ./spec/ffi/callback_spec.rb:925 # Callback interop from fiddle to fiddle

git bisect shows https://github.com/ruby/fiddle/commit/91d0ea98490e7c69f9dd9ab11386fd4f62bd4f24 is the bad commit.

For now, reporting to fiddle side.

kou commented 3 weeks ago

Thanks for your report. The bad commit you identified introduced a limitation that "Function name must be String" limitation. I've removed the limitation. The ffi gem tests worked again. I'll release a new version. It'll be included in Ruby 3.4.0.