Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

jnistubs on linux

Thread view: 
Jim - 09 Mar 2006 20:26 GMT
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.
Jim - 11 Mar 2006 13:49 GMT
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.

> Going crazy.
> Trying to use the jnistubs code as found in the Solaris JNI book - it's been
[quoted text clipped - 20 lines]
>
> Thanks for any help.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.