JNI applications fail because shared libraries cannot be found

Bug #1027122 reported by Nikolaus Rath
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
uwsgi (Ubuntu)
Invalid
High
Unassigned

Bug Description

The update from OpenJDK 6b20-1.9.13-0ubuntu1~10.04.1 to 6b21.2-2ubuntu0.10.04.1 in Lucid broke JNI applications. Attempts to run a JNI application now crash with:

$ jScope
Load library java.lang.UnsatisfiedLinkError: /opt/mdsplus/lib/libJavaMds.so: libhpi.so: cannot open shared object file: No such file or directory
java.lang.UnsatisfiedLinkError: /opt/mdsplus/lib/libJavaMds.so: libhpi.so: cannot open shared object file: No such file or directory
 at java.lang.ClassLoader$NativeLibrary.load(Native Method)
 at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
 at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
 at java.lang.Runtime.loadLibrary0(Runtime.java:840)
 at java.lang.System.loadLibrary(System.java:1047)
 at jScope.LocalDataProvider.<clinit>(LocalDataProvider.java:192)
 at java.lang.Class.forName0(Native Method)/
 at java.lang.Class.forName(Class.java:186)
 at jScope.jScopeWaveContainer.SetDataServer(jScopeWaveContainer.java:1360)

Downgrading all packages created by the OpenJDK source package to 6b20-1.9.13-0ubuntu1~10.04.1 fixes the problem.

libhpi.so is located in /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/native_threads/libhpi.so, so the problem can be temporarily fixed by setting LD_LIBRARY_PATH=/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/native_threads/. However, this path is of course very dependent on the used JRE, so it needs to be set by java itself.

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: openjdk-6-jre-headless 6b24-1.11.3-1ubuntu0.10.04.1
ProcVersionSignature: Ubuntu 3.0.0-23.38~lucid1-server 3.0.36
Uname: Linux 3.0.0-23-server x86_64
Architecture: amd64
Date: Fri Jul 20 11:11:48 2012
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: openjdk-6

Revision history for this message
Nikolaus Rath (nikratio) wrote :
tags: added: regression-update
Nikolaus Rath (nikratio)
description: updated
Changed in openjdk-6 (Ubuntu):
importance: Undecided → High
Revision history for this message
Steve Beattie (sbeattie) wrote :

Hi Nikolaus,

Sorry you're having troubles. Can you explain how you installed mdsplus? I am unable to reproduce this using Ubuntu 10.04 LTS and following the instructions for Ubuntu11 and stable in http://www.mdsplus.org/index.php/Latest_Ubuntu_Packages. Also, attempts to do simpler things with JNI didn't show anything like this.

Can you strace the open() calls to see what path it's looking for for libhpi.so, like so:

  strace -o /tmp/jScope.strace -f -e trace=open jScope

That will put the output of the strace in /tmp/jScope.strace.

Another possibility path for debugging would by to modify the jScope shell script to add '-verbose:jni' to the $java invocation, and capturing the output. That said, if I did not have libsybdb.so.5 installed, I got a similar error for libsybdb.so.5, and the verbose jni information did not give anything additionally relevant to it.

I also note that the path of libhpi.so did not change between the two versions of openjdk-6-jre-headless.

That said, I note that http://h1svr.anu.edu.au/wiki/Hardware/Computers/prl45 reports a similar error finding libhpi.so on Ubuntu 12.04 LTS. Due to multiarch changes in the distribution, I wonder if the patch that was added to openjdk-6 to fix https://bugs.launchpad.net/ubuntu/+source/openjdk-6/+bug/737603 is causing problems here.

Thanks.

Changed in openjdk-6 (Ubuntu):
status: New → Incomplete
Revision history for this message
Nikolaus Rath (nikratio) wrote :

Hi Steve,

Thanks for your efforts! Our MDSplus installation has been compiled from source. I have attached the strace output as well as the debugging output.

Revision history for this message
Nikolaus Rath (nikratio) wrote :
Changed in openjdk-6 (Ubuntu):
status: Incomplete → New
Revision history for this message
Nikolaus Rath (nikratio) wrote :

I tried running NativeTest.java from bug 737603 with the same environment variables that are used for the jScope invocation (exept the classtpath):

Before the upgrade:

$ LD_LIBRARY_PATH=:/opt/hbt/valen/lib/i686/:/opt/mdsplus//lib SHLIB_PATH=:/opt/mdsplus//lib DYLD_LIBRARY_PATH=:/opt/mdsplus//lib /usr/bin/java -Xmx128M NativeTest JavaMds
java.library.path: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64::/opt/hbt/valen/lib/i686/:/opt/mdsplus//lib:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
sun.boot.library.path: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64
System.mapLibraryName(): libJavaMds.so

After the upgrade:

$ LD_LIBRARY_PATH=:/opt/hbt/valen/lib/i686/:/opt/mdsplus//lib SHLIB_PATH=:/opt/mdsplus//lib DYLD_LIBRARY_PATH=:/opt/mdsplus//lib /usr/bin/java -Xmx128M NativeTest JavaMds
java.library.path: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64::/opt/hbt/valen/lib/i686/:/opt/mdsplus//lib:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
sun.boot.library.path: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64
System.mapLibraryName(): libJavaMds.so
Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/mdsplus/lib/libJavaMds.so: libhpi.so: cannot open shared object file: No such file or directory
 at java.lang.ClassLoader$NativeLibrary.load(Native Method)
 at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
 at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
 at java.lang.Runtime.loadLibrary0(Runtime.java:840)
 at java.lang.System.loadLibrary(System.java:1047)
 at NativeTest.main(NativeTest.java:6)

Revision history for this message
Steve Beattie (sbeattie) wrote :

Hi Nikolaus,

Sorry, I've been unable to reproduce this issue. Can you tell me specifically what version of MDSplus version you're running, as well as any specific configure options that you built it with, so I can further attempt to reproduce what you're seeing? I also tried running NativeTest.java from bug 737603 as you did and it loaded the JavaMDS library just fine; however, I noticed when strace'ing it that it never attempted to open libhpi.so in doing so, and I'm not sure why (hence my asking for configure options that may affect this).

I should also point out that bug 737603 is a bit of a red herring; I re-examined the openjdk-6 packaging and the patch for bug 737603 is included in the package but is not actually applied during the build (I was going to prepare a test package for you with that patch disabled...).

A couple more things to look at to diagnose this:

* can you run 'ldd /opt/mdsplus/lib/libJavaMds.so' to confirm that it's the library itself that has the dependency on libhpi.so?

* can you re-run the NativeTest.java test, both with the older version of java installed where it succeeds and the failing versions, with the addition of the LD_DEBUG environment variable set to 'all' (i.e. add 'LD_DEBUG=all' to the command line)? I'd like to see what symbols are causing libhpi.so to get pulled in and how the resolution is happening.

Thanks, and my apologies for the difficulties this upgrade has caused.

Revision history for this message
Nikolaus Rath (nikratio) wrote : Re: [Bug 1027122] Re: JNI applications fail because shared libraries cannot be found

Hi Steve,

I can give you a shell account on a server affected by the problem.
Would that help?

If so, please send me an ssh key.

Best,

   -Nikolaus

--
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C

affects: openjdk-6 (Ubuntu) → uwsgi (Ubuntu)
Revision history for this message
dino99 (9d9) wrote :

Closing that outdated report as EOL has been reached long time ago

Changed in uwsgi (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.