We have a Java EE application running in JBoss that uses JNA (3.5.1) to make a call to a Native C++ library on RedHat 6.3.
The C++ library we were using used to be 32-bit but has recently been ported to 64-bit. We are now in the process of updating JBoss application to run using the 64-bit JVM (RHEL JRE 1.6_43.1).
When we ported the Native library to 64-bit we used a C++ test stub to test all of the public interfaces that are used by JNA - all of these tests pass without any problems.
Now, when I try to access the 64-bit Native library using JNA I get the following error:
#
# A fatal error has been detected by the Java Runtime Environment
#
# SIGSEGV (0xb) at pc=0x0000003718b32fbc, pid=4489, tid=140200254654208
#
# JRE version: 6.0_22-b22
# Java VM: OpenJDK 64-Bit Server VM (20.0-b11 mixed mode linux-amd64 compresssed oops)
# Derivative: IcedTea6 1.10.6
# Distribution: Red Hat Enterprise Linux Server release 6.2 (Santiago), package rhel-1.43.1.10.6.el6_2-x86_64
# Problematic frame:
# C [libc.so.6+0x132fbc] __tls_get_addr@@GLIBC_2.3+0x132fbc
#
# ...
I have traced the source of the error down to a call that is being made to a third party library that is called from within our recently ported Native library. The call to the third party library is being made with a set of values that originate from within the Native library, not values that get passed into the library.
So for SOME REASON we get the following behaviour:
- Call Native library from C++ test stub: Success
- Call Native library from Java via JNA: Failure (segfault)
extern "C"
{
const char* getId(const char* interface);
int isValidFeature(const char* feature, const char* interface);
}
public interface NativeInterface extends Library
{
boolean isValidFeature (String feature, String interface);
String getHostId(String interface);
}