Segmentation fault running JvCreateJavaVM possile bug ?
lucian
lucian@mediafusion.co.jp
Wed Jan 29 16:29:00 GMT 2003
Hello everybody!
I`m trying to make a dll out of a set of java packages .
Working with gcc on cygwin win2k.
I`m doing this because I need to make a COM out of them.
Anyways I get this segmentation fault running JvCreateJavaVM so I made the example
down below (a simple c program) to localize the problem.
This is how it goes:
foo.c:
#include <gcj/cni.h>
extern "C" int foo(void);
int foo(void){
JvCreateJavaVM(NULL);
return 0;
}
_________________________
fooexp.def:
EXPORTS
foo
__________________________
#include <stdio.h>
extern int foo(void);
int main(){
printf("foo(): %d\n", foo());
return 0;
}
_____________________________
then compile foo.c (with g++ cause it imports cni . thats makes the export "C" part necesary)
$ g++ -c foo.c
make a dll (use fooexp.def to define the interface correctly)
$ dllwrap -o foo.dll --def fooexp.def foo.o -lgcj -lz -liconv
and compile against this dll
$ gcc callfoo.c foo.dll -o callfoo_dll.exe
and running ./callfoo.exe gives segmentation fault.
This is the output from gdb
....
Starting program: /cygdrive/c/baito/callfoo_dll.exe
Program received signal SIGSEGV, Segmentation fault.
0x69c5ce0f in _Unwind_Find_FDE ()
(gdb) bt
#0 0x69c5ce0f in _Unwind_Find_FDE ()
#1 0x69c5af00 in uw_frame_state_for ()
#2 0x69c5b2b6 in uw_init_context_1 ()
#3 0x69c5b4d6 in _Unwind_RaiseException ()
#4 0x69b81074 in _Jv_Throw () from /cygdrive/c/baito/foo.dll
#5 0x69bd0e2f in _Jv_ThreadStart(java::lang::Thread*, int*, void (*)(java::lang::Thread*)) ()
#6 0x69b8e601 in java::lang::Thread::start() ()
#7 0x69b82cf3 in _Jv_CreateJavaVM(void*) () from /cygdrive/c/baito/foo.dll
#8 0x69c5de21 in JvCreateJavaVM(void*) ()
#9 0x69b81012 in lab () from /cygdrive/c/baito/foo.dll
#10 0x004010c1 in main ()
#11 0x61007638 in foo_dll_iname ()
#12 0x6100791d in foo_dll_iname ()
#13 0x004026a2 in cygwin_crt0 ()
#14 0x0040103c in mainCRTStartup ()
#15 0x77e57903 in _libkernel32_a_iname ()
(gdb)
It looks like a bug in gcj (or cygwin) !?Or did I miss anything ?
But the thing is that linking against the object file works ok :
$ gcc callfoo.c foo.o -lgcj -lz -liconv -o callfoo_o.exe
and ./callfoo_o.exe works.Actualy in this way I could compile the whole java package (including a
big chunk from kawa) but I HAVE to make a dll to make lib out of it :
$ implib foo.lib fooimp.def
$ bcc32 callfoo.c foo.lib
and ofcourse ./callfoo.exe dies but I cant analyze that deeply and it`s not that helpfull anyways
because the problem is not here.
I`m writing to you cause i`m not sure if it`s cygwin problem or a gcj problem.
I`m a linux user so I`m not really familiar with dlls and cygwin so I may be making a basic mistake.
I really need help on this one so anybody who has 5 minutes to try this would you be so nice
to try it ?
Any help will be more than welcomed .
Thanx in advance .
--
Lucian
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list