cloudius-systems / osv

OSv, a new operating system for the cloud.
osv.io
Other
4.11k stars 605 forks source link

missing libraries in Java module #601

Open nyh opened 9 years ago

nyh commented 9 years ago

Philipp Suter tried a Java application which did some image manipulation, and crashed on a missing symbol cmsSetLogErrorHandler:

Failed looking up symbol cmsSetLogErrorHandler 
[backtrace]
0x0000000000343609 <elf::object::symbol(unsigned int)+185>
0x0000000000344f58 <elf::object::resolve_pltgot(unsigned int)+136>
0x0000000000345135 <elf_resolve_pltgot+69>
0x0000000000391bce <???+3742670>
0x000020001d5f92bf <???+492802751>
0x000010000700f87d <Java_java_lang_ClassLoader_00024NativeLibrary_load+269>
...
0x000010000a804c7a <Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader+554>

The problem is that OpenJDK includes a shared library libjavalcms.so (see external/x64/openjdk.bin/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.7.4.fc20.x86_64/jre/lib/amd64/libjavalcms.so) for doing color management or something like that.

Unfortunately, this library is not stand-alone:

$ ldd libjavalcms.so
    linux-vdso.so.1 =>  (0x00007fff9ddf1000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f8a04161000)
    libawt.so => not found
    liblcms2.so.2 => /lib64/liblcms2.so.2 (0x00007f8a03f06000)
    libjava.so => not found
    libjvm.so => not found
    libc.so.6 => /lib64/libc.so.6 (0x00007f8a03b48000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8a0392c000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003020e00000)

So we need to also copy liblcms2.so.2 to the OSv image (you can put it in /, or with the rest of the Java shared objects), and we did not. Philip tried it from his host, and it solved the bug.

The solution is to add this liblcms2 to external/, and have our Java image include it. We've already done this for other libraries we noticed are needed (like freetype). There might be more dependencies like this we are missing, so it's worth checking.

nyh commented 8 years ago

Waldek Kozaczuk noticed another missing dependency, in openjdk8-fedora:

$ ldd apps/openjdk8-fedora/install/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.102-2.b14.fc26.x86_64/jre/lib/amd64/libsunec.so
    linux-vdso.so.1 (0x00007ffd6ecc2000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f16b6ac8000)
    libssl3.so => /lib64/libssl3.so (0x00007f16b687e000)
    libsmime3.so => /lib64/libsmime3.so (0x00007f16b6656000)
    libnss3.so => /lib64/libnss3.so (0x00007f16b632d000)
    libnssutil3.so => /lib64/libnssutil3.so (0x00007f16b60ff000)
    libplds4.so => /lib64/libplds4.so (0x00007f16b5efa000)
    libplc4.so => /lib64/libplc4.so (0x00007f16b5cf5000)
    libnspr4.so => /lib64/libnspr4.so (0x00007f16b5ab6000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f16b5899000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f16b5695000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f16b538c000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f16b4fc9000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f16b4db2000)
    /lib64/ld-linux-x86-64.so.2 (0x000055c874cec000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f16b4b9c000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f16b4993000)

We probably are missing a few of those, but he specifically saw the NSPR library missing when trying to run the "derby" database.

nyh commented 7 years ago

I also saw the same missing library (libnsp4) when trying to run tomcat (from apps/) with openjdk8-fedora:

$ scripts/build image=openjdk8-fedora,tomcat
$ scripts/run -V
...
could not load libssl3.so
could not load libsmime3.so
could not load libnss3.so
could not load libnssutil3.so
could not load libplds4.so
could not load libplc4.so
could not load libnspr4.so
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-3.b16.fc26.x86_64/jre/lib/amd64/libsunec.so: failed looking up symbol PR_CallOnce

Presumably, the missing PR_CallOnce function is supposed to come from libnspr4.so, which is missing from the image because the openjdk8-fedora module neglects to add it.

nyh commented 7 years ago

Fix for openjdk8-fedora to download and include all the dependencies of libsunsec.so and libjavalcms.so was committed to apps.git. The same problem for the other JREs in apps.git has NOT yet been fixed. Moreover, even for openjdk8-fedora, there may be additional JRE libraries with additional dependencies we are missing - we need to check before closing this issue.