Problem starting VM from a thread

Gong Su gongsu at cs.columbia.edu
Fri Oct 30 21:41:27 PST 1998


Hi all, I wonder if anyone can shed some light on this. I'm doing it on
Linux x86 (both 2.0.36 and 2.1.126).

I'm trying to start the VM from a thread (C code). What I did was taking
the main.c of the kick off program, changing main() into some other function,
e.g., KaffeMain(), and I added another function called StartEngine() which
creates a thread and passes KaffeMain as the function argument. I made
necessary changes to simulate the arguments being passed to KaffeMain().
The main.c is compiled into a .so with (among others) the switches,

-fPIC -shared -lkaffevm -lpthread

StartEngine() itself is dlopen-ed and invoked by another main program. The
process dies with a segmentation fault on the attempt to load the first
class library; and here is the message I got by using the "-v" argument,

Loading java/lang/Object.class(/usr/share/kaffe/Klasses.jar) 
[compressed]Segmentation fault (core dumped)

The interesting thing is, if I call KaffeMain directly from StartEngine
without creating a thread, the process still dies with the same message
as long as both "-lkaffevm" and "-lpthread" (in either order) are used
for compiling main.c; however if I only use "-lkaffevm", the process works
fine. Does anyone have any idea what might have gone wrong? Is this the
right way to dynamically start a VM from C and feed it some Java code?
Is there any sample code (besides the main.c) that shows how to do this?
Thanks in advance for any help.

/Gong




More information about the kaffe mailing list