JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6438

"TypeError: can't convert Array into String" from ffi code in 1.9 mode

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.6
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: None
    • Labels:
      None
    • Patch Submitted:
      Yes
    • Number of attachments :
      0

      Description

      TypeError: can't convert Array into String
                      join at org/jruby/RubyArray.java:1868
                initialize at /projects/eds_test/share/jruby-1.6.6/lib/ruby/site_ruby/shared/ffi/ffi.rb:65
           attach_function at /projects/eds_test/share/jruby-1.6.6/lib/ruby/site_ruby/shared/ffi/library.rb:154
                      each at org/jruby/RubyArray.java:1614
           attach_function at /projects/eds_test/share/jruby-1.6.6/lib/ruby/site_ruby/shared/ffi/library.rb:150
                    LibXML at /Users/Shared/RubyGems/gems/nokogiri-1.4.4-java/lib/nokogiri/ffi/libxml.rb:275
                  Nokogiri at /Users/Shared/RubyGems/gems/nokogiri-1.4.4-java/lib/nokogiri/ffi/libxml.rb:42
                    (root) at /Users/Shared/RubyGems/gems/nokogiri-1.4.4-java/lib/nokogiri/ffi/libxml.rb:41
      
      
      # jruby-1.6.6/lib/ruby/site_ruby/shared/ffi/library.rb" line 154
      raise FFI::NotFoundError.new(cname.to_s, ffi_libraries.map { |lib| lib.name })
      

      The code above is passing an array to FFI::NotFoundError#initialize(function, *libraries)

      The following monkey patch to jruby-1.6.6/lib/ruby/site_ruby/shared/ffi/ffi.rb seemed to resolve the issue for me.

      require 'ffi'
      
      module FFI
        class NotFoundError < NativeError
          def initialize(function, *libraries)
            libraries.flatten!
            super("Function '#{function}' not found in [#{libraries[0].nil? ? 'current process' : libraries.join(", ")}]")
          end
        end
      end
      

        Activity

        Hide
        Lenny Marks added a comment -

        This does not happen in JRuby-1.6.6 1.8 mode. I believe this is a regression from JRuby-1.6.5.1 as it only started happening after we upgraded.

        Show
        Lenny Marks added a comment - This does not happen in JRuby-1.6.6 1.8 mode. I believe this is a regression from JRuby-1.6.5.1 as it only started happening after we upgraded.
        Hide
        Wayne Meissner added a comment -

        Should be fixed in commit 29f7010adf5ba0a2e585cf581893f0341b3aba97

        Show
        Wayne Meissner added a comment - Should be fixed in commit 29f7010adf5ba0a2e585cf581893f0341b3aba97
        Hide
        Hiro Asari added a comment -

        I cherry-picked this to the 1.6 branch as well (5d9474a).

        Show
        Hiro Asari added a comment - I cherry-picked this to the 1.6 branch as well (5d9474a).

          People

          • Assignee:
            Thomas E Enebo
            Reporter:
            Lenny Marks
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: