delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/01/29/04:14:47

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Wed, 29 Jan 2003 18:00:38 +0900
From: lucian <lucian AT mediafusion DOT co DOT jp>
To: cygwin AT cygwin DOT com
Subject: Segmentation fault running JvCreateJavaVM possile bug ?
Message-Id: <20030129180038.600322c9.lucian@mediafusion.co.jp>
Mime-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019