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

Could not load module /usr/lib/libc.a on AIX #12

Closed
tajila opened this issue Feb 8, 2016 · 5 comments
Closed

Could not load module /usr/lib/libc.a on AIX #12

tajila opened this issue Feb 8, 2016 · 5 comments
Milestone

Comments

@tajila
Copy link

tajila commented Feb 8, 2016

On AIX using JRuby v9.0.4 on a 32bit JVM, JRuby fails to start up because it is unable to load /usr/lib/libc.a. The following is the full stack trace.

Caused by:
java.lang.UnsatisfiedLinkError: Could not load module /usr/lib/libc.a.
    The module has an invalid magic number.
        loadNativeLibraries at jnr/ffi/provider/jffi/NativeLibrary.java:87
         getNativeLibraries at jnr/ffi/provider/jffi/NativeLibrary.java:70
           getSymbolAddress at jnr/ffi/provider/jffi/NativeLibrary.java:49
          findSymbolAddress at jnr/ffi/provider/jffi/NativeLibrary.java:59
      generateInterfaceImpl at jnr/ffi/provider/jffi/AsmLibraryLoader.java:117
                loadLibrary at jnr/ffi/provider/jffi/AsmLibraryLoader.java:59
                loadLibrary at jnr/ffi/provider/jffi/NativeLibraryLoader.java:43
                       load at jnr/ffi/LibraryLoader.java:290
                loadLibrary at jnr/ffi/Library.java:127
                loadLibrary at jnr/ffi/Library.java:82
                loadLibrary at jnr/ffi/Library.java:67
                   <clinit> at jnr/enxio/channels/Native.java:64
                       libc at jnr/enxio/channels/Native.java:69
                      write at jnr/enxio/channels/Native.java:112
                      write at jnr/enxio/channels/NativeDeviceChannel.java:86
                      write at org/jruby/util/io/PosixShim.java:102
                        run at org/jruby/util/io/OpenFile.java:1334
                        run at org/jruby/util/io/OpenFile.java:1325
                executeTask at org/jruby/RubyThread.java:1355
              writeInternal at org/jruby/util/io/OpenFile.java:2233
                   binwrite at org/jruby/util/io/OpenFile.java:2174
                     fwrite at org/jruby/util/io/OpenFile.java:2038
                      write at org/jruby/RubyIO.java:1438
                      write at org/jruby/RubyIO.java:1410
                    finvoke at org/jruby/RubyClass.java:756
                     invoke at org/jruby/runtime/Helpers.java:401
                       warn at org/jruby/RubyKernel.java:1174
               cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:313
                       call at org/jruby/runtime/callsite/CachingCallSite.java:163
                processCall at org/jruby/ir/interpreter/InterpreterEngine.java:290
                  interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
             INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:102
                    execute at org/jruby/ir/interpreter/Interpreter.java:89
                    execute at org/jruby/ir/interpreter/Interpreter.java:32
                    execute at org/jruby/ir/IRTranslator.java:42
             runInterpreter at org/jruby/Ruby.java:837
                   loadFile at org/jruby/Ruby.java:2900
                       load at org/jruby/runtime/load/LibrarySearcher.java:236
                       load at org/jruby/runtime/load/LibrarySearcher.java:35
  tryLoadingLibraryOrScript at org/jruby/runtime/load/LoadService.java:896
          smartLoadInternal at org/jruby/runtime/load/LoadService.java:541
              requireCommon at org/jruby/runtime/load/LoadService.java:426
                    require at org/jruby/runtime/load/LoadService.java:392
              requireCommon at org/jruby/RubyKernel.java:946
                  require19 at org/jruby/RubyKernel.java:939
                       call at org/jruby/internal/runtime/methods/JavaMethod.java:380
               cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:313
                       call at org/jruby/runtime/callsite/CachingCallSite.java:163
                processCall at org/jruby/ir/interpreter/InterpreterEngine.java:290
                  interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
             INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:102
                    execute at org/jruby/ir/interpreter/Interpreter.java:89
                    execute at org/jruby/ir/interpreter/Interpreter.java:32
                    execute at org/jruby/ir/IRTranslator.java:42
             runInterpreter at org/jruby/Ruby.java:837
                   loadFile at org/jruby/Ruby.java:2900
                       load at org/jruby/runtime/load/LibrarySearcher.java:236
                       load at org/jruby/runtime/load/LibrarySearcher.java:35
  tryLoadingLibraryOrScript at org/jruby/runtime/load/LoadService.java:896
          smartLoadInternal at org/jruby/runtime/load/LoadService.java:541
              requireCommon at org/jruby/runtime/load/LoadService.java:426
                    require at org/jruby/runtime/load/LoadService.java:392
              requireCommon at org/jruby/RubyKernel.java:946
                  require19 at org/jruby/RubyKernel.java:939
                       call at org/jruby/internal/runtime/methods/JavaMethod.java:380
               cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:313
                       call at org/jruby/runtime/callsite/CachingCallSite.java:163
                processCall at org/jruby/ir/interpreter/InterpreterEngine.java:290
                  interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
             INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:102
                    execute at org/jruby/ir/interpreter/Interpreter.java:89
                    execute at org/jruby/ir/interpreter/Interpreter.java:32
                    execute at org/jruby/ir/IRTranslator.java:42
             runInterpreter at org/jruby/Ruby.java:837
                   loadFile at org/jruby/Ruby.java:2900
                       load at org/jruby/runtime/load/LibrarySearcher.java:236
                       load at org/jruby/runtime/load/LibrarySearcher.java:35
  tryLoadingLibraryOrScript at org/jruby/runtime/load/LoadService.java:896
          smartLoadInternal at org/jruby/runtime/load/LoadService.java:541
              requireCommon at org/jruby/runtime/load/LoadService.java:426
                    require at org/jruby/runtime/load/LoadService.java:392
              requireCommon at org/jruby/RubyKernel.java:946
                  require19 at org/jruby/RubyKernel.java:939
                       call at org/jruby/internal/runtime/methods/JavaMethod.java:380
               cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:313
                       call at org/jruby/runtime/callsite/CachingCallSite.java:163
                processCall at org/jruby/ir/interpreter/InterpreterEngine.java:290
                  interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
             INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:102
                    execute at org/jruby/ir/interpreter/Interpreter.java:89
                    execute at org/jruby/ir/interpreter/Interpreter.java:32
                    execute at org/jruby/ir/IRTranslator.java:42
             runInterpreter at org/jruby/Ruby.java:837
                   loadFile at org/jruby/Ruby.java:2900
                       load at org/jruby/runtime/load/LibrarySearcher.java:236
                       load at org/jruby/runtime/load/LibrarySearcher.java:35
  tryLoadingLibraryOrScript at org/jruby/runtime/load/LoadService.java:896
          smartLoadInternal at org/jruby/runtime/load/LoadService.java:541
              requireCommon at org/jruby/runtime/load/LoadService.java:426
                    require at org/jruby/runtime/load/LoadService.java:392
              requireCommon at org/jruby/RubyKernel.java:946
                  require19 at org/jruby/RubyKernel.java:939
                       call at org/jruby/internal/runtime/methods/JavaMethod.java:380
               cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:313
                       call at org/jruby/runtime/callsite/CachingCallSite.java:163
                processCall at org/jruby/ir/interpreter/InterpreterEngine.java:290
                  interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
             INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:102
                    execute at org/jruby/ir/interpreter/Interpreter.java:89
                    execute at org/jruby/ir/interpreter/Interpreter.java:32
                    execute at org/jruby/ir/IRTranslator.java:42
             runInterpreter at org/jruby/Ruby.java:837
                   loadFile at org/jruby/Ruby.java:2900
                       load at org/jruby/runtime/load/LibrarySearcher.java:236
                       load at org/jruby/runtime/load/LibrarySearcher.java:35
  tryLoadingLibraryOrScript at org/jruby/runtime/load/LoadService.java:896
          smartLoadInternal at org/jruby/runtime/load/LoadService.java:541
              requireCommon at org/jruby/runtime/load/LoadService.java:426
                    require at org/jruby/runtime/load/LoadService.java:392
              requireCommon at org/jruby/RubyKernel.java:946
                  require19 at org/jruby/RubyKernel.java:939
                       call at org/jruby/internal/runtime/methods/JavaMethod.java:380
               cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:313
                       call at org/jruby/runtime/callsite/CachingCallSite.java:163
                processCall at org/jruby/ir/interpreter/InterpreterEngine.java:290
                  interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
             INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:102
                    execute at org/jruby/ir/interpreter/Interpreter.java:89
                    execute at org/jruby/ir/interpreter/Interpreter.java:32
                    execute at org/jruby/ir/IRTranslator.java:42
             runInterpreter at org/jruby/Ruby.java:837
                   loadFile at org/jruby/Ruby.java:2900
                       load at org/jruby/runtime/load/LibrarySearcher.java:236
                       load at org/jruby/runtime/load/LibrarySearcher.java:35
                       load at org/jruby/runtime/load/LoadService.java:336
                 loadCommon at org/jruby/RubyKernel.java:965
                     load19 at org/jruby/RubyKernel.java:957
                       call at org/jruby/internal/runtime/methods/DynamicMethod.java:201
                       call at org/jruby/internal/runtime/methods/DynamicMethod.java:197
               cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:313
                       call at org/jruby/runtime/callsite/CachingCallSite.java:163
                processCall at org/jruby/ir/interpreter/InterpreterEngine.java:290
                  interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
             INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:102
                    execute at org/jruby/ir/interpreter/Interpreter.java:89
                    execute at org/jruby/ir/interpreter/Interpreter.java:32
                    execute at org/jruby/ir/IRTranslator.java:42
             runInterpreter at org/jruby/Ruby.java:837
                   loadFile at org/jruby/Ruby.java:2900
                       load at org/jruby/runtime/load/ExternalScript.java:58
        loadFromClassLoader at org/jruby/runtime/load/LoadService.java:362
             initRubyKernel at org/jruby/Ruby.java:1779
                       init at org/jruby/Ruby.java:1275
                newInstance at org/jruby/Ruby.java:330
                internalRun at org/jruby/Main.java:272
                        run at org/jruby/Main.java:233
                       main at org/jruby/Main.java:200

The cause of the problem is line 64 in jnr/enxio/channels/Native.java

static final LibC libc = Library.loadLibrary("c", LibC.class);

This ends up calling dlopen(..) with "/usr/lib/libc.a.". On AIX the correct way to do this is "/usr/lib/libc.a(shr.o)" for 32bit and "/usr/lib/libc.a(shr_64.o)" for 64bit.

I tried this on AIX6.1 and AIX7.1 using 32-bit IBM Java8 JDK.

@headius
Copy link
Member

headius commented Mar 8, 2016

Can you help us modify this to search properly for shared objects on AIX?

@tajila
Copy link
Author

tajila commented Mar 8, 2016

Sure, I can submit a pull request sometime before the end of the week.

@tajila
Copy link
Author

tajila commented Mar 14, 2016

I should have mentioned, the #14 changes have a dependency on the jnr/jnr-ffi#60 changes.

@headius
Copy link
Member

headius commented Mar 14, 2016

With these PRs, do you consider this issue resolved?

We probably should also make this change for https://github.com/jnr/jnr-posix.

@headius headius added this to the 0.12 milestone Mar 14, 2016
@tajila
Copy link
Author

tajila commented Mar 14, 2016

Yes this specific issue is resolved. There is still another problem with startup on AIX 32-bit but it appears to be related to jruby/jruby#3495 (comment), so I will post some comments there.

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