RMI, JNI combo crashes JVM

From: Andrew Greensted (ajg112_at_ohm.york.ac.uk)
Date: 07/29/04


Date: Thu, 29 Jul 2004 13:51:17 +0100

Hi All,

I've got some java weirdness going on, and would really appreciate a
hand sorting it out.

I'm using JNI to communicate with a digital IO card. The native
functions are very simple, they're just reading and writing to the ISA
bus, so it's just inb and outb function calls. On it's own this set up
works fine.

However, I want to access the machine with the IO card remotely,
basically so one machine is collecting data, then passes it onto another
for processing and storing. So to do this I'm trying to use RMI.

I've successfully got RMI talking to a remote object. But when I
integrate the JNI stuff the server JVM crashes.

Here's the set up:

Client: Processing & storing data

Server: Running rmiregistry,
        Running a server object with methods using JNI to talk to IOCard

Every runs fine, until the client calls a method that uses JNI to call a
native function using lowlevel outb/inb functions. Then the JVM crashes
(dump is below). Other native functions that don't use the inb/outb seem
to return fine.

The client exits with the following Exception:

Error unmarshaling return header; nested exception is:
         java.io.EOFException

java.io.EOFException
         at java.io.DataInputStream.readByte(DataInputStream.java:278)
         at
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:189)
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
         at sysComms.SysCommsControllerImp_Stub.setJTAGAddress(Unknown
Source)
         at SysCommsTest.<init>(SysCommsTest.java:78)
         at SysCommsTest.main(SysCommsTest.java:108)

I've set the security manager to AllPermission. Apart from this, I'm
really stumped. Any advice, help or hints would be gratefully received!!

Cheers
Andy

Here's the dump:

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : 11 occurred at PC=0x4CC6FA85
Function=(null)+0x4CC6FA85
Library=/root/bioNodeCode/jIOCard/libIOInterface.so

NOTE: We are unable to locate the function name symbol for the error
       just occurred. Please refer to release documentation for possible
       reason and solutions.

Current Java thread:
         at jIOCard.IOInterface.nativeWriteData(Native Method)
         at jIOCard.IOInterface.writeData(IOInterface.java:68)
         at
sysComms.SysCommsControllerImp.setJTAGAddress(SysCommsControllerImp.java:121)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
         at sun.rmi.transport.Transport$1.run(Transport.java:148)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
         at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
         at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
         at java.lang.Thread.run(Thread.java:534)

Dynamic libraries:
08048000-0804e000 r-xp 00000000 03:02 41360 /opt/j2sdk1.4.2_02/bin/java
0804e000-0804f000 rw-p 00005000 03:02 41360 /opt/j2sdk1.4.2_02/bin/java
40000000-40018000 r-xp 00000000 03:02 2892 /lib/ld-2.3.2.so
40018000-40019000 rw-p 00017000 03:02 2892 /lib/ld-2.3.2.so
4001a000-4001d000 r--s 00000000 03:02 40769
/opt/j2sdk1.4.2_02/jre/lib/ext/dnsns.jar
4001d000-4002b000 r-xp 00000000 03:02 2891 /lib/i686/libpthread.so.0
4002b000-4002c000 rw-p 0000d000 03:02 2891 /lib/i686/libpthread.so.0
4006e000-40070000 r-xp 00000000 03:02 2901 /lib/libdl.so.2
40070000-40071000 rw-p 00002000 03:02 2901 /lib/libdl.so.2
40071000-4019d000 r-xp 00000000 03:02 2889 /lib/i686/libc.so.6
4019d000-401a2000 rw-p 0012c000 03:02 2889 /lib/i686/libc.so.6
401a5000-4059f000 r-xp 00000000 03:02 40737
/opt/j2sdk1.4.2_02/jre/lib/i386/client/libjvm.so
4059f000-405bb000 rw-p 003f9000 03:02 40737
/opt/j2sdk1.4.2_02/jre/lib/i386/client/libjvm.so
405cd000-405df000 r-xp 00000000 03:02 2904 /lib/libnsl.so.1
405df000-405e0000 rw-p 00011000 03:02 2904 /lib/libnsl.so.1
405e2000-40604000 r-xp 00000000 03:02 2890 /lib/i686/libm.so.6
40604000-40605000 rw-p 00021000 03:02 2890 /lib/i686/libm.so.6
40605000-4060d000 r-xp 00000000 03:02 40731
/opt/j2sdk1.4.2_02/jre/lib/i386/native_threads/libhpi.so
4060d000-4060e000 rw-p 00007000 03:02 40731
/opt/j2sdk1.4.2_02/jre/lib/i386/native_threads/libhpi.so
4060e000-40612000 rw-s 00000000 03:02 29957 /tmp/hsperfdata_root/3985
40612000-40622000 r-xp 00000000 03:02 40742
/opt/j2sdk1.4.2_02/jre/lib/i386/libverify.so
40622000-40624000 rw-p 0000f000 03:02 40742
/opt/j2sdk1.4.2_02/jre/lib/i386/libverify.so
40624000-40644000 r-xp 00000000 03:02 40743
/opt/j2sdk1.4.2_02/jre/lib/i386/libjava.so
40644000-40646000 rw-p 0001f000 03:02 40743
/opt/j2sdk1.4.2_02/jre/lib/i386/libjava.so
40646000-4065a000 r-xp 00000000 03:02 40745
/opt/j2sdk1.4.2_02/jre/lib/i386/libzip.so
4065a000-4065d000 rw-p 00013000 03:02 40745
/opt/j2sdk1.4.2_02/jre/lib/i386/libzip.so
4065d000-41ff5000 r--s 00000000 03:02 41353
/opt/j2sdk1.4.2_02/jre/lib/rt.jar
4203f000-42055000 r--s 00000000 03:02 40772
/opt/j2sdk1.4.2_02/jre/lib/sunrsasign.jar
42055000-42130000 r--s 00000000 03:02 41261
/opt/j2sdk1.4.2_02/jre/lib/jsse.jar
42130000-42141000 r--s 00000000 03:02 40773
/opt/j2sdk1.4.2_02/jre/lib/jce.jar
42141000-4269a000 r--s 00000000 03:02 41299
/opt/j2sdk1.4.2_02/jre/lib/charsets.jar
44742000-4474f000 r--s 00000000 03:02 40771
/opt/j2sdk1.4.2_02/jre/lib/ext/ldapsec.jar
4474f000-44750000 r--s 00000000 03:02 29899
/root/bioNodeCode/jIOCard/jIOCard.jar
4c953000-4c97f000 r--p 00000000 03:02 5299
/usr/lib/locale/en_GB/LC_CTYPE
4cb83000-4cb9f000 r--s 00000000 03:02 40768
/opt/j2sdk1.4.2_02/jre/lib/ext/sunjce_provider.jar
4cb9f000-4cc5b000 r--s 00000000 03:02 41300
/opt/j2sdk1.4.2_02/jre/lib/ext/localedata.jar
4cc5b000-4cc5e000 r--s 00000000 03:02 29940
/root/bioNodeCode/sysComms/sysComms.jar
4cc5e000-4cc6e000 r-xp 00000000 03:02 40748
/opt/j2sdk1.4.2_02/jre/lib/i386/libnet.so
4cc6e000-4cc6f000 rw-p 0000f000 03:02 40748
/opt/j2sdk1.4.2_02/jre/lib/i386/libnet.so
4cc6f000-4cc70000 r-xp 00000000 03:02 33916
/root/bioNodeCode/jIOCard/libIOInterface.so
4cc70000-4cc71000 rw-p 00000000 03:02 33916
/root/bioNodeCode/jIOCard/libIOInterface.so
4cc72000-4cc7b000 r-xp 00000000 03:02 2907 /lib/libnss_files.so.2
4cc7b000-4cc7c000 rw-p 00008000 03:02 2907 /lib/libnss_files.so.2
4cf01000-4cf02000 r-xp 00000000 03:02 40760
/opt/j2sdk1.4.2_02/jre/lib/i386/librmi.so
4cf02000-4cf03000 rw-p 00000000 03:02 40760
/opt/j2sdk1.4.2_02/jre/lib/i386/librmi.so

Heap at VM Abort:
Heap
  def new generation total 576K, used 396K [0x44750000, 0x447f0000,
0x44c30000)
   eden space 512K, 77% used [0x44750000, 0x447b30e0, 0x447d0000)
   from space 64K, 0% used [0x447d0000, 0x447d0000, 0x447e0000)
   to space 64K, 0% used [0x447e0000, 0x447e0000, 0x447f0000)
  tenured generation total 1408K, used 130K [0x44c30000, 0x44d90000,
0x48750000)
    the space 1408K, 9% used [0x44c30000, 0x44c50ad8, 0x44c50c00,
0x44d90000)
  compacting perm gen total 4096K, used 2213K [0x48750000, 0x48b50000,
0x4c750000)
    the space 4096K, 54% used [0x48750000, 0x48979578, 0x48979600,
0x48b50000)

Local Time = Thu Jul 29 12:46:44 2004
Elapsed Time = 12
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_02-b03 mixed mode)
#
# An error report file has been saved as hs_err_pid3985.log.
# Please refer to the file for further information.
#

-- 
Andrew Greensted            Department of Electronics
Bio-Inspired Engineering    University of York, UK
Tel: +44(0)1904 432379      Mailto: ajg112@ohm.york.ac.uk
Fax: +44(0)1904 433224      Web: www.bioinspired.com


Relevant Pages

  • Re: trouble passing float array from C to java method
    ... running in the background and calling my Java function when it gathers ... After every call to JNI you should check for errors (there are, in fact, a few ... This can fail. ... This can fail by throwing a Java exception. ...
    (comp.lang.java.programmer)
  • Re: corba questions
    ... > You could try using Java JNI to interface between Delphi & Java. ... To use the JNI piece would require a Java client communicating ... or handling request with the Delphi client, ...
    (borland.public.delphi.non-technical)
  • how to show C line number AND exception type in JNI exception stack trace?
    ... Does anyone know how to display BOTH the C code line number and the Java exception type in a JNI exception stack trace in Java? ... In the C code, check for the exception, and return immediately to the Java code, where it catches the NoSuchMethodError Throwable object and displays the stack trace, which only indicates the Java code line numbers and type of the Throwable object. ...
    (comp.lang.java.programmer)
  • Re: Calling java APIs from a c program
    ... i am trying to call some java APIs from c. ... i use the standatd JNI ... The way you handle exception is inherently unsafe, ... When a Java exception is pending, only very few JNI functions are allowed. ...
    (comp.lang.java.programmer)
  • Re: alternative to lua
    ... I'm stuck with Java 1.5, and I cannot use jni, but ... it was a good thought Chris. ... script interpretator by myself (one in the c++ client, ...
    (comp.lang.java.programmer)