Java LoadLibrary Issues on Linux

I am loading a Library on Linux through System.LoadLibrary( ) call. (Previously asked about here)

A new twist is that I discovered gstack, so I can see where it is actually frozen.. One red flag I see is this:

Thread 15 (Thread 0xb73feb90 (LWP 12892)):
#0  0xb7f57402 in __kernel_vsyscall ()
#1  0x0075ebc5 in [email protected]@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2  0x7fd2416c in system__task_primitives__operations(short, long,...)(...)( *) () from /app/gnatpro6.2.2-linux/lib/gcc/i686-pc-linux-gnu/4.3.3/adalib/libgnarl-6.2.so
#3  0x7fd2cd13 in system__tasking__stages__activate_tasks () from /app/gnatpro6.2.2-linux/lib/gcc/i686-pc-linux-gnu/4.3.3/adalib/libgnarl-6.2.so
#4  0x7fd2272c in system__interrupts___elabb () from /app/gnatpro6.2.2-linux/lib/gcc/i686-pc-linux-gnu/4.3.3/adalib/libgnarl-6.2.so
#5  0xb7377e37 in loadinit () from /home/user1/workspace/javaLinux/lib/libload.so
#6  0xb7377ecd in __do_global_ctors_aux () from /home/user1/workspace/javaLinux/lib/libload.so
#7  0xb7377579 in _init () from /home/user1/workspace/javaLinux/lib/libload.so
#8  0x005b73f3 in call_init () from /lib/ld-linux.so.2
#9  0x005b7503 in _dl_init_internal () from /lib/ld-linux.so.2
#10 0x005baeab in dl_open_worker () from /lib/ld-linux.so.2
#11 0x005b7036 in _dl_catch_error () from /lib/ld-linux.so.2
#12 0x005ba652 in _dl_open () from /lib/ld-linux.so.2
#13 0x0074ec6d in dlopen_doit () from /lib/libdl.so.2
#14 0x005b7036 in _dl_catch_error () from /lib/ld-linux.so.2
#15 0x0074f2ec in _dlerror_run () from /lib/libdl.so.2
#16 0x0074eba4 in [email protected]@GLIBC_2.1 () from /lib/libdl.so.2
#17 0xb792c099 in os::dll_load(char const*, char*, int) () from /home/user1/tools/Linux/jdk1.6.0_17/jre/lib/i386/server/libjvm.so
#18 0xb77e0cd9 in JVM_LoadLibrary () from /home/user1/tools/Linux/jdk1.6.0_17/jre/lib/i386/server/libjvm.so
#19 0xb7394cac in Java_java_lang_ClassLoader_00024NativeLibrary_load () from /home/user1/tools/Linux/jdk1.6.0_17/jre/lib/i386/libjava.so
#20 0xb43554aa in ?? ()
#21 0x086a9510 in ?? ()
#22 0xb73fdf34 in ?? ()
#23 0xb73fdf30 in ?? ()
#24 0xb434e08d in ?? ()
#25 0xb73fdf00 in ?? ()
#26 0x00000000 in ?? ()

Specifically this: #17 0xb792c099 in os::dll_load

Shouldn’t this be calling into a Linux load library call, not a dll call? Any ideas why it would make the wrong call?

Answer

I think, this is just a matter of naming things. It seems, that the JVM authors preferred to name their wrapper dll_load instead of so_load. If you look at the stacktrace (in particular, the frames immediately above in the list), you see

[email protected]@GLIBC_2.1 () from /lib/libdl.so.2

which actually is the Linux equivalent to LoadLibrary under windows.

Leave a Reply

Your email address will not be published. Required fields are marked *