This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Segfault JvCreateJavaVM when doing dlopen, dlclose, dlopen
- From: Matthijs van de Water <matthijs dot van dot de dot water at gmail dot com>
- To: java at gcc dot gnu dot org
- Date: Thu, 12 Mar 2009 11:30:52 +0100
- Subject: Segfault JvCreateJavaVM when doing dlopen, dlclose, dlopen
Hello,
I'm having a problem with a Java .so (compiled with gcj-4.3 for ARM)
that I use in a C++ program as a dynamically loadable plugin.
The plugin works fine as long as I keep it loaded into memory. Because
I'm working on an embedded system, I'd like to be able to unload the
plugin when it's not in use to save memory.
I'm trying the following:
1. dlopen() the .so, we call an init function in this .so plugin which
uses JvCreateJaveVM() and JvAttatchCurrentThread()
2. Call some functions in the .so plugin. These functions use Java objects.
3. Unref all Java objects and call unload function in the .so that
calls JvDetachCurrentThread()
4. dlclose() the .so
5. dlopen() the .so again (as step 1)
6. The code crashes with a SEGV when making calls into Java code (as step 2)
I've not been able to properly pinpoint the crash yet, but it seems to
crash outside my own code (in libgcj somewhere).
Before I spend hours of debugging, could one of you at least tell me
if what I'm trying to do should be working?
The one 'strange' thing I'm doing is that I've statically compiled a
PIC version of libgcj.a into the .so plugin to avoid the huge
libgcj.so on my embedded system. This has been working without
problems so-far, however.
--
Regards,
Matthijs van de Water