Forum: JRuby FFI on Turkish Windows

Posted by Matt Hauck (Guest)
on 2012-08-01 06:56
(Received via mailing list)
I'm getting a problem loading the FFI library on Turkish Windows 2008 
(x64 w/ x32 java) and wondered if anybody else has run into this before. 
It looks like it is using the turkish "i" without a dot in place of the 
standard "i" in the architecture string. So I get an error like this:

irb(main):001:0> require 'ffi'
LoadError: Unsupported platform: ı386-unknown
        from org/jruby/RubyKernel.java:1033:in `require'
        from c:/jruby-1.6.7.2/lib/ruby/site_ruby/shared/ffi/ffi.rb:69:in 
`(root)'
        from org/jruby/RubyKernel.java:1033:in `require'
        from c:/jruby-1.6.7.2/lib/ruby/site_ruby/shared/ffi/ffi.rb:1:in 
`(root)'
        from org/jruby/RubyKernel.java:1033:in `require'
        from c:/jruby-1.6.7.2/lib/ruby/site_ruby/shared/ffi.rb:1:in 
`evaluate'
        from org/jruby/RubyKernel.java:1083:in `eval'
        from c:/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:158:in `eval_input'
        from c:/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:271:in `signal_status'
        from c:/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:155:in `eval_input'
        from org/jruby/RubyKernel.java:1410:in `loop'
        from org/jruby/RubyKernel.java:1183:in `catch'
        from c:/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:154:in `eval_input'
        from c:/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:71:in `start'
        from org/jruby/RubyKernel.java:1183:in `catch'
        from c:/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:70:in `start'
        from c:\jruby-1.6.7.2\bin\jirb:13:in `(root)'



This happens when I straight up require "ffi-internal.so" as well. 
Unfortunately, I cannot seem to find this file anywhere on my system and 
can't figure out what code this is running to figure out what the 
problem is.

Any suggestions?

--
Matt Hauck
Posted by Andrew Grimm (Guest)
on 2012-08-01 08:19
(Received via mailing list)
This is just guessing, but what is the text on line 69 of
c:/jruby-1.6.7.2/lib/ruby/site_ruby/shared/ffi/ffi.rb ?

Thanks,

Andrew
Posted by Wayne Meissner (Guest)
on 2012-08-01 12:52
(Received via mailing list)
On 1 August 2012 14:54, Matt Hauck <matthauck@gmail.com> wrote:
> This happens when I straight up require "ffi-internal.so" as well.
> Unfortunately, I cannot seem to find this file anywhere on my system and
> can't figure out what code this is running to figure out what the problem
> is.

The code is in org/jruby/ext/ffi/Platform.java - look for
determineCPU() and determineOS().

Those methods try to infer the cpu and os from the os.name and os.arch
java properties, and if they don't match any supported combination,
then it won't load FFI.

So, start by checking what os.name and os.arch print out.  It may be
that we have to do charset conversion on those properties before
comparing them.  Or hardcode the turkish variants in there.
Posted by Matt Hauck (Guest)
on 2012-08-02 01:48
(Received via mailing list)
Thanks for the pointer Wayne, it looks like that's where the issue is, 
depending on toLowerCase() which is returning the turkish "i". Filed a 
bug: http://jira.codehaus.org/browse/JRUBY-6808

--
Matt Hauck
Posted by Wayne Meissner (Guest)
on 2012-08-02 23:52
(Received via mailing list)
Matt, can you test jruby-master?

I did a few changes to FFI and the underlying jffi library to always
use Locale.ENGLISH when doing case conversions.
Posted by Matt Hauck (Guest)
on 2012-08-03 01:33
(Received via mailing list)
Almost there. It's struggling with the "i" in windows now. This is what 
I'm seeing:

C:\Users\Administrator\jruby>bin\jirb
A­u 03, 2012 2:28:01 AM jnr.ffi.provider.jffi.NativeRuntime 
buildNativeTypeAliases
SEVERE: failed to load type aliases: java.lang.ClassNotFoundException: 
jnr/ffi/provider/jffi/platform/x86_64/w²ndows/TypeAliases
irb(main):001:0> require 'ffi'
NameError: uninitialized constant FFI::Type::VOID
        from org/jruby/RubyModule.java:2688:in `const_missing'
        from 
C:/Users/Administrator/jruby/lib/ruby/shared/ffi/types.rb:59:in `FF
I'
        from 
C:/Users/Administrator/jruby/lib/ruby/shared/ffi/types.rb:30:in `(r
oot)'
        from org/jruby/RubyKernel.java:1021:in `require'
        from 
C:/Users/Administrator/jruby/lib/ruby/shared/rubygems/custom_requir
e.rb:1:in `(root)'
        from 
C:/Users/Administrator/jruby/lib/ruby/shared/rubygems/custom_requir
e.rb:36:in `require'
        from org/jruby/RubyKernel.java:1021:in `require'
        from 
C:/Users/Administrator/jruby/lib/ruby/shared/ffi/ffi.rb:71:in `(roo
t)'
        from 
C:/Users/Administrator/jruby/lib/ruby/shared/rubygems/custom_requir
e.rb:1:in `(root)'
        from org/jruby/RubyKernel.java:1021:in `require'
        from 
C:/Users/Administrator/jruby/lib/ruby/shared/rubygems/custom_requir
e.rb:36:in `require'
        from C:/Users/Administrator/jruby/lib/ruby/shared/ffi.rb:1:in 
`(root)'
        from org/jruby/RubyKernel.java:1067:in `eval'
        from 
C:/Users/Administrator/jruby/lib/ruby/shared/rubygems/custom_requir
e.rb:1:in `(root)'
        from 
C:/Users/Administrator/jruby/lib/ruby/shared/rubygems/custom_requir
e.rb:36:in `require'
        from (irb):1:in `evaluate'
        from org/jruby/RubyKernel.java:1392:in `loop'
        from org/jruby/RubyKernel.java:1175:in `catch'
        from org/jruby/RubyKernel.java:1175:in `catch'
        from C:\Users\Administrator\jruby\bin\jirb:13:in `(root)'


Should we continue this conversation on the bug for the sake of keeping 
it on record?

I'm not sure if this is a good time or not, but it would probably be a 
good idea to make this change extensively throughout jruby to stop these 
bugs from popping up in other places as well?

--
Matt Hauck
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.