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

ffi memory pointer workaround #14

Closed
jsvd opened this issue May 20, 2015 · 8 comments
Closed

ffi memory pointer workaround #14

jsvd opened this issue May 20, 2015 · 8 comments

Comments

@jsvd
Copy link

jsvd commented May 20, 2015

have you considered applying the workaround you proposed in jruby/jruby#2293:

if RUBY_PLATFORM == 'java' && ENV_JAVA['sun.arch.data.model'] == '64'
  :ulong_long
else
  :uintptr_t
end

so this library is usable in JRuby 64bit until the fix lands upstream?

@djberg96
Copy link
Collaborator

Let me check to see if they fixed this in pre2. If not, I'll add the fix.

@jsvd
Copy link
Author

jsvd commented May 20, 2015

It is not fixed.

irb(main):006:0> RUBY_DESCRIPTION
=> "jruby 9.0.0.0.pre2 (2.2.2) 2015-04-28 2755ae0 Java HotSpot(TM) 64-Bit Server VM 25.31-b07 on 1.8.0_31-b13 +jit [Windows 7-amd64]"
irb(main):007:0> FFI::MemoryPointer.new(:uintptr_t).read_pointer
IndexError: Memory access offset=0 size=8 is out of bounds
        from org/jruby/ext/ffi/AbstractMemory.java:1922:in `read_pointer'
        from (irb):7:in `<eval>'
        from org/jruby/RubyKernel.java:1005:in `eval'
        from org/jruby/RubyKernel.java:1315:in `loop'
        from org/jruby/RubyKernel.java:1125:in `catch'
        from org/jruby/RubyKernel.java:1125:in `catch'
        from jirb:13:in `<top>'

@djberg96
Copy link
Collaborator

Ok, pushed out 0.6.3, thanks.

@jsvd
Copy link
Author

jsvd commented May 21, 2015

@djberg96 I'm not sure what 66a128a did but as long as there are calls to FFI::MemoryPointer.new(:uintptr_t) in the code it will still fail

@djberg96
Copy link
Collaborator

Well, that wasn't very thorough of me, was it. I think I accidentally ran the tests with a 32-bit JRuby.

I'll get that fixed today.

@djberg96 djberg96 reopened this May 21, 2015
@djberg96
Copy link
Collaborator

Hm, having some problems getting my custom typedefs imported at the instance level. Gonna have to spend a bit more time on this than I thought.

@djberg96
Copy link
Collaborator

Hm, been thinking about this some more. I'm not sure how much more I want to integrate workarounds in my code for something that JRuby should fix. Let me see if I can get them to fix this in time for 9000.

@djberg96
Copy link
Collaborator

Ok, they found the bug and fixed it. The fix will be in the next release. I'm simply going to put a caveat in the README that you must use JRuby 9k or later.

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

2 participants