jnistubs on linux

J

Jim

Going crazy.
Trying to use the jnistubs code as found in the Solaris JNI book - it's been
modified for linux.
We can use it to run things like printf with several parameter variations,
but when we attempt to execute functions in our own shared library, we crash
with a segv 11.

The Main.java calls a ecrtr_initS() with several parms and it returns OK -
all this function is write some info to a file (and the file is written).
Main.java then calls a ecrtr_init(), again with several parms. ecrtr_init()
calls ecrtr_initF(int) which calls init_Global(void). All init_Global does
is set a bunch of global variables.
The segv always occurs in the instruction "personality = -1;"; but if I move
that around or comment out the entire call, it fails somewhere else.

The shared lib is fairly complex, with threads and SSL, but it never even
gets to that complicated part.
We use jdk1.4.2_09 and linux kernel 2.4.21 (also tried with 2.6 kernel).

It sort of smells like a stack corruption, but haven't been able to pinpoint
it - BTW, it works great on Win32.
Anybody else had any troubles like this with the jnistubs on linux?

Thanks for any help.
 
J

Jim

OK, I will answer my own question. The primary file in the shared lib had
some global variables (chars and ints) and they were in the included .h
file. I changed those globals to be static and all started working.
Now I didn't change all globals (the ones also used by other files), but
only the ones localized to the one main file.
It seems for some reason, those globals were not only not initialized, but
the memory for them was not allocated yet.

I have no idea why this would be so. But now it works OK.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top