StackOverflow in a plugin using JNI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

StackOverflow in a plugin using JNI

Jérémy Ohana-2
hello,
I am writing some ImageJ plugins that use C code with JNI. This C program
starts with arrays initialization (about 12 arrays with size = 14000).
When I compile and execute this C prog, it works. When I call it from a java
class through JNI, it works. But When I call it from an ImageJ plugins the
program is stoppped during the arrays initialization and the following error
message is displayed :

An irrecoverable stack overflow has occurred.
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGSEGV (0xb) at pc=0xb1815b04, pid=22544, tid=2971655088
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_09-b01 mixed mode, sharing)
# Problematic frame:
# C  [libtomo4.so+0xb04]  Java_Tomographie_14_tracking+0x210
#
# An error report file with more information is saved as hs_err_pid22544.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

I tried to make more memory available for ImageJ, I tried 512Mo and 1024Mo,
but it didn't change anything. I hope that someone has an idea about this
problem, any advice would be very welcome. Thank you.
Jeremy
Reply | Threaded
Open this post in threaded view
|

Re: StackOverflow in a plugin using JNI

Albert Cardona
Jeremy,

C code is sneaky, particularly arrays, and even more particularly when
passing them to and from the JVM. I recommend you to use valgrind on
your C program first, and then to check very carefully when are you
freeing the arrays that you pass to and from the JVM, and whether you
are doing so exactly in compliance with the JNI guidelines.

The fact that the C code runs fine in one situation and not in another
is very symptomatic of improper memory deallocation, and of modifying
values beyond the limits of an array.

Hope it helps.

Albert