hi! I already posted a problem running vCreateJavaVM(NULL); It seems it can't be run inside a thread?? I now produced a very small example showing the crash. The backtrace was: [Switching to Thread 16386 (LWP 18107)] 0x40559247 in GC_push_all_eager () from /usr/lib/libgcj.so.4 (gdb) bt #0 0x40559247 in GC_push_all_eager () from /usr/lib/libgcj.so.4 #1 0x405592c2 in GC_push_all_stack () from /usr/lib/libgcj.so.4 #2 0x40555776 in GC_push_all_stacks () from /usr/lib/libgcj.so.4 #3 0x4055bfd7 in GC_default_push_other_roots () from /usr/lib/libgcj.so.4 #4 0x4055a4a2 in GC_push_roots () from /usr/lib/libgcj.so.4 #5 0x40558056 in GC_mark_some () from /usr/lib/libgcj.so.4 #6 0x4054fbbe in GC_stopped_mark () from /usr/lib/libgcj.so.4 #7 0x4054f8b5 in GC_try_to_collect_inner () from /usr/lib/libgcj.so.4 #8 0x4055ad6d in GC_init_inner () from /usr/lib/libgcj.so.4 #9 0x4055aa0e in GC_init () from /usr/lib/libgcj.so.4 #10 0x40553ae9 in GC_init_gcj_malloc () from /usr/lib/libgcj.so.4 #11 0x4054d1e5 in _Jv_InitGC() () from /usr/lib/libgcj.so.4 #12 0x40361baa in _Jv_CreateJavaVM(void*) () from /usr/lib/libgcj.so.4 #13 0x08048df3 in JvCreateJavaVM (vm_args=0x0) at cni.h:125 #14 0x08048bf9 in testclass::testThread() (this=0x8049c98) at crashme.cpp:38 #15 0x08048bd5 in testclass::testThreadStartRoutine(void*) (data=0x8049c98) at crashme.cpp:27 #16 0x40037cca in omni_thread_wrapper () from /usr/lib/libomnithread.so.3 #17 0x408dcf60 in pthread_start_thread () from /lib/i686/libpthread.so.0 #18 0x408dd0fe in pthread_start_thread_event () from /lib/i686/libpthread.so.0 #19 0x40a17327 in clone () from /lib/i686/libc.so.6 Hope this helps to find the problem. The used software was: gcc (GCC) 3.3.1 (SuSE Linux) libomnithread.so.3 from omniORB-4.0.2-3 Hope this helps to finally find the problem! Thanks Fabian
#include <omnithread.h> #include <stdio.h> #include <stdlib.h> #include <string> #include <iostream> #include <gcj/cni.h> #include <java/lang/Throwable.h> class testclass { public: testclass(); void run(); static void * testThreadStartRoutine(void *data); void testThread(); }; testclass::testclass() { } void * testclass::testThreadStartRoutine(void * data) { std::cout << "thread started" << std::endl; testclass * tc=(testclass*) data; tc->testThread(); return 0; } void testclass::testThread() { try { //java VM already initialized? static bool javaVM = false; if (!javaVM) { JvCreateJavaVM(NULL); javaVM = true; } // attach current thread to java. should have no sideeffects if already attached JvAttachCurrentThread(NULL, NULL); // create space-manager, this would be the call to create a method creating a java object // m_jLayoutArea = SpaceManagerUtils::toRectangle2i(m_layoutArea); } catch (java::lang::Throwable *t) { throw t; } while (1) { std::cout << "in thread"<< std::endl; } } void testclass::run() { (new omni_thread(&testThreadStartRoutine, this))->start(); } int main(int argc, char **argv) { testclass *t = new testclass(); /***** * Here is the error, if done like this it crashes * if you remove t->run() and replace it with t->testThread() it starts to work! */ t->run(); //t->testThread(); while (1) { sleep(10); } }
LIBS = -L/usr/lib -lomnithread all: crashme crashme: crashme.o $(EXTERNAL_OBJECTS) gcj $(LIBS) -o $@ $^ %.o: %.cpp g++ $(INCLUDES) -c -g -o $(OBJDIR)$@ $^ clean: rm crashme crashme.o