Skip to content

JRuby fails to load FFI support with obscure error when /tmp is not writable #1302

@qerub

Description

@qerub
$ sudo chmod 1775 /tmp
$ java -Djruby.native.verbose=true -jar jruby-complete.jar -rffi -e :ok
Failed to load native POSIX impl; falling back on Java impl. Stacktrace follows.
java.lang.UnsatisfiedLinkError: could not load FFI provider jnr.ffi.provider.jffi.Provider
        at jnr.ffi.provider.InvalidProvider$1.loadLibrary(InvalidProvider.java:30)
        at jnr.ffi.LibraryLoader.load(LibraryLoader.java:228)
        at jnr.ffi.Library.loadLibrary(Library.java:123)
        at jnr.posix.POSIXFactory$DefaultLibCProvider$SingletonHolder.<clinit>(POSIXFactory.java:219)
        at jnr.posix.POSIXFactory$DefaultLibCProvider.getLibC(POSIXFactory.java:223)
        at jnr.posix.BaseNativePOSIX.<init>(BaseNativePOSIX.java:37)
        at jnr.posix.LinuxPOSIX.<init>(LinuxPOSIX.java:20)
        at jnr.posix.POSIXFactory.loadLinuxPOSIX(POSIXFactory.java:95)
        at jnr.posix.POSIXFactory.loadNativePOSIX(POSIXFactory.java:69)
        at jnr.posix.POSIXFactory.loadPOSIX(POSIXFactory.java:38)
        at jnr.posix.LazyPOSIX.loadPOSIX(LazyPOSIX.java:33)
        at jnr.posix.LazyPOSIX.posix(LazyPOSIX.java:29)
        at jnr.posix.LazyPOSIX.isatty(LazyPOSIX.java:183)
        at org.jruby.Main.handleRaiseException(Main.java:509)
        at org.jruby.Main.main(Main.java:202)
Caused by: java.lang.ExceptionInInitializerError
        at jnr.ffi.provider.jffi.NativeRuntime.getInstance(NativeRuntime.java:49)
        at jnr.ffi.provider.jffi.Provider.<init>(Provider.java:29)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
        at java.lang.Class.newInstance0(Class.java:374)
        at java.lang.Class.newInstance(Class.java:327)
        at jnr.ffi.provider.FFIProvider$SystemProviderSingletonHolder.getInstance(FFIProvider.java:60)
        at jnr.ffi.provider.FFIProvider$SystemProviderSingletonHolder.<clinit>(FFIProvider.java:49)
        at jnr.ffi.provider.FFIProvider.getSystemProvider(FFIProvider.java:35)
        at jnr.ffi.Runtime$SingletonHolder.<clinit>(Runtime.java:85)
        at jnr.ffi.Runtime.getSystemRuntime(Runtime.java:70)
        at jnr.posix.NativePOSIX.<init>(NativePOSIX.java:9)
        at jnr.posix.BaseNativePOSIX.<init>(BaseNativePOSIX.java:35)
        ... 9 more
Caused by: java.lang.IllegalStateException: Can't overwrite cause
        at java.lang.Throwable.initCause(Throwable.java:337)
        at com.kenai.jffi.Type$Builtin.lookupTypeInfo(Type.java:252)
        at com.kenai.jffi.Type$Builtin.getTypeInfo(Type.java:237)
        at com.kenai.jffi.Type.resolveSize(Type.java:155)
        at com.kenai.jffi.Type.size(Type.java:138)
        at jnr.ffi.provider.jffi.NativeRuntime$TypeDelegate.size(NativeRuntime.java:178)
        at jnr.ffi.provider.AbstractRuntime.<init>(AbstractRuntime.java:48)
        at jnr.ffi.provider.jffi.NativeRuntime.<init>(NativeRuntime.java:57)
        at jnr.ffi.provider.jffi.NativeRuntime.<init>(NativeRuntime.java:41)
        at jnr.ffi.provider.jffi.NativeRuntime$SingletonHolder.<clinit>(NativeRuntime.java:53)
        ... 24 more
LoadError: Could not load FFI Provider: (NotImplementedError) FFI not available: null
 See http://jira.codehaus.org/browse/JRUBY-4583
  require at org/jruby/RubyKernel.java:1084
  require at jar:file:/tmp/jruby-sandbox/vendor/jruby-complete-with-bundler.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55
   (root) at jar:file:/tmp/jruby-sandbox/vendor/jruby-complete-with-bundler.jar!/META-INF/jruby.home/lib/ruby/shared/ffi/ffi.rb:69
  require at org/jruby/RubyKernel.java:1084
   (root) at jar:file:/tmp/jruby-sandbox/vendor/jruby-complete-with-bundler.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
  require at jar:file:/tmp/jruby-sandbox/vendor/jruby-complete-with-bundler.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55
  require at org/jruby/RubyKernel.java:1084
   (root) at jar:file:/tmp/jruby-sandbox/vendor/jruby-complete-with-bundler.jar!/META-INF/jruby.home/lib/ruby/shared/ffi.rb:1
$ sudo chmod 1777 /tmp
$ java -Djruby.native.verbose=true -jar jruby-complete.jar -rffi -e :ok
Successfully loaded native POSIX impl.

I noticed this when I accidentally changed permissions for /tmp. A more informative message would be helpful. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions