Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: uninitialized constant Fiddle::CParser::TYPE_SIZE_T #5955

Closed
ankane opened this issue Nov 5, 2019 · 14 comments
Closed

NameError: uninitialized constant Fiddle::CParser::TYPE_SIZE_T #5955

ankane opened this issue Nov 5, 2019 · 14 comments

Comments

@ankane
Copy link

@ankane ankane commented Nov 5, 2019

Hi, I'm running into an error with fiddle with the latest JRuby on MacOS 10.14.6 (may affect other platforms as well).

Environment

  • jruby 9.2.8.0 (2.5.3) 2019-08-12 a1ac7ff Java HotSpot(TM) 64-Bit Server VM 25.192-b12 on 1.8.0_192-b12 +jit [darwin-x86_64]

Expected Behavior

No error when size_t is used. Here's a simple script to reproduce:

require "fiddle/import"

module Hello
  extend Fiddle::Importer
  dlload "libc.dylib" # change extension on other platforms
  extern "size_t puts(char* str)"
end

(this is not the actual interface for puts but works for demonstration)

Actual Behavior

Raises

NameError: uninitialized constant Fiddle::CParser::TYPE_SIZE_T
Did you mean?  Fiddle::TYPE_INT
    const_missing at org/jruby/RubyModule.java:3746
      parse_ctype at /Users/andrew/.rbenv/versions/jruby-9.2.8.0/lib/ruby/stdlib/fiddle/cparser.rb:164
  parse_signature at /Users/andrew/.rbenv/versions/jruby-9.2.8.0/lib/ruby/stdlib/fiddle/cparser.rb:92
           extern at /Users/andrew/.rbenv/versions/jruby-9.2.8.0/lib/ruby/stdlib/fiddle/import.rb:166
    <class:Hello> at repro.rb:6
           <main> at repro.rb:3
@ahorek ahorek mentioned this issue Nov 5, 2019
@ahorek
Copy link
Contributor

@ahorek ahorek commented Nov 8, 2019

hi @ankane !
do you have a real world example that you would like to support on jruby?

@ankane
Copy link
Author

@ankane ankane commented Nov 8, 2019

Hey @ahorek, thanks for the response! I've created a fiddle branch in a number of projects to see if it was possible to switch from FFI. Here are a few that are affected by this issue.

And a few that are affected by #5956.

@ankane
Copy link
Author

@ankane ankane commented Nov 8, 2019

Also, seeing errors with malloc.

require "fiddle"

Fiddle::Pointer.malloc(100)

Throws

NameError: uninitialized constant Fiddle::Pointer::LibC
  const_missing at org/jruby/RubyModule.java:3746
         malloc at /Users/andrew/.rbenv/versions/jruby-9.2.8.0/lib/ruby/stdlib/fiddle/jruby.rb:168
         <main> at malloc.rb:3

@ahorek
Copy link
Contributor

@ahorek ahorek commented Nov 8, 2019

Also, seeing errors with malloc. - yeah, that one will be fixed by jruby/ruby#2

@ankane
Copy link
Author

@ankane ankane commented Nov 8, 2019

Awesome, thanks!

@ahorek
Copy link
Contributor

@ahorek ahorek commented Nov 8, 2019

ok, there are 2 more failures

DatasetTest#test_weight:
NoMethodError: undefined method `[]=' for #<Fiddle::Pointer:0x13cc0b90>
Did you mean?  []
    /lightgbm/lib/lightgbm/ffi.rb:172:in `write_array'
    /lightgbm/lib/lightgbm/ffi.rb:121:in `write_array_of_float'
    /lightgbm/lib/lightgbm/dataset.rb:43:in `initialize'
    /lightgbm/test/dataset_test.rb:21:in `test_weight'
DatasetTest#test_data_string:
TypeError: cannot convert parameter to native pointer
    /lightgbm/lib/lightgbm/ffi.rb:24:in `LGBM_DatasetCreateFromFile'
    /lightgbm/lib/lightgbm/dataset.rb:23:in `initialize'
    /lightgbm/test/dataset_test.rb:5:in `test_data_string'

I think I can fix the first one, but the second one will be more tricky

@ankane
Copy link
Author

@ankane ankane commented Nov 8, 2019

For 2, is that due to string -> pointer conversion?

@ahorek
Copy link
Contributor

@ahorek ahorek commented Jan 13, 2020

string -> pointer conversion is fixed #5960 , but there're still issues #6034

@headius
Copy link
Member

@headius headius commented Jan 13, 2020

Anything left here or can we call this one fixed?

@ahorek
Copy link
Contributor

@ahorek ahorek commented Jan 13, 2020

there's still work in order to fully support those gems, but the original issue is fixed.

@headius
Copy link
Member

@headius headius commented Jan 13, 2020

@ahorek I prefer individual issues for individual problems, so we'll call this fixed and move on to others.

@headius headius closed this as completed Jan 13, 2020
@headius headius added this to the JRuby 9.2.10.0 milestone Jan 13, 2020
@headius
Copy link
Member

@headius headius commented Jan 13, 2020

@ankane @ahorek Please file additional unique issues for anything else that's still broken. Doesn't have to be an issue-per-failure or anything that fine-grained, but something better than "these half dozen gems don't work". Thank you!

@ankane
Copy link
Author

@ankane ankane commented Jan 14, 2020

Thanks @headius! Will test out the changes when the next version of JRuby is out (unless there's an easy way to get JRuby head with rbenv, but didn't see it in the list).

@headius
Copy link
Member

@headius headius commented Jan 14, 2020

@ankane I know rvm supports jruby-head but not sure about rbenv. If you want to just download a tarball, we push snapshot builds of that to Maven here: https://oss.sonatype.org/content/repositories/snapshots/org/jruby/jruby-dist/

Just put the bin dir in PATH and you're up and running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants