I am having an issue where Java is trying to load an .so object but cannot map it, so it crashes. How can I debug in a situation like this?
Here is the command (trying to run the HDFView utility, incidentally):
/usr/lib/jvm/java-11-openjdk-amd64//bin/java -Djava.library.path=/usr/lib/jni/:/usr/lib/x86_64-linux-gnu/ -Dswing.systemlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -classpath /usr/share/java/jhdf.jar:/usr/share/java/jhdf5.jar:/usr/share/java/jhdfobj.jar:/usr/share/java/jhdf4obj.jar:/usr/share/java/jhdf5obj.jar:/usr/share/java/jhdfview.jar:/usr/share/java/jgraph.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-nop.jar ncsa.hdf.view.HDFView -root /usr/share/doc/libjhdf-doc/
Here is the error output:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so: libxcb.so.1: failed to map segment from shared object at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method) at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430) at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487) at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684) at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2617) at java.base/java.lang.Runtime.load0(Runtime.java:767) at java.base/java.lang.System.load(System.java:1831) at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method) at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430) at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487) at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684) at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2638) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829) at java.base/java.lang.System.loadLibrary(System.java:1867) at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1395) at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1393) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1392) at java.desktop/java.awt.Toolkit.(Toolkit.java:1425) at java.desktop/java.awt.Component.(Component.java:621)
Other interesting facts:
Running the same command with "sudo" in front gives the same error but with a different library.
Running the same command after first elevating with "sudo su" gives no error, although the application does not run as expected.
The libraries have read permission. I have tried elevating them to execute permission, but this did not change anything.
Running the command in ValGrind produced a very large amount of complaint-filled output but eventually ran the app instead of crashing.
I am having trouble using gdb to attach to the process and extract info.
I have gone through the source code glibc and openjdk11 but found no insight. Strace and ltrace seemed not to help.
Many SO questions deal with classpath and library path issues, but this seems not to be the problem. As far as I can tell, it is finding the libraries just fine, but then it can't map them.
The library is in a file system that is not mounted noexec.
Output requested by comment
From ldd /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so
linux-vdso.so.1 (0x00007ffda2ffd000)
libgtk3-nocsd.so.0 => /usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (0x00007f6efd9b0000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6efd612000)
libawt.so => /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt.so (0x00007f6efd342000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f6efd130000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f6efcdf8000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f6efcbee000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f6efc9ea000)
libXtst.so.6 => /usr/lib/x86_64-linux-gnu/libXtst.so.6 (0x00007f6efc7e4000)
libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f6efc5d4000)
libjava.so
=> /usr/lib/jvm/java-11-openjdk-amd64/lib/libjava.so (0x00007f6efc3a7000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6efc188000)
libc.so.6
=> /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6efbd97000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6efde1a000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f6efbb6f000)
libjvm.so => not found
libverify.so => /usr/lib/jvm/java-11-openjdk-amd64/lib/libverify.so (0x00007f6efb960000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f6efb75c000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f6efb556000)
libjvm.so => not found
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f6efb341000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6efb139000)
Output from file -L /usr/lib/x86_64-linux-gnu/libxcb.so.1:
/usr/lib/x86_64-linux-gnu/libxcb.so.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=4cc7a1f024b6a0511ed01e149f2f198c2532e5fd, stripped
Since it says that libjvm is needed, I switched to openjdk-8, which has libjvm.so. Then the results were
GLib (gthread-posix.c): Unexpected error from C library during 'malloc': Cannot allocate memory. Aborting.
Responding to this, added -Xmx500M to the call (using either version of Java), and it runs without diagnostics. However, the application does not work. For example, I am able to view an HDF5 file, but it claims the file is empty when it is not. It also can't create new files, both of which are standard functionalities for this application. So I am not sure if I have just masked the problem or solved it.