gcj win32 frustration
Rutger Ovidius
r_ovidius@eml.cc
Mon Aug 2 16:39:00 GMT 2004
Hello,
I'm having quite a painful time trying to get gcj on win32 to produce
reliable, portable executables. It is also quite frustrating trying to
debug or produce test cases so I'll try to sum up my long and painful
experience here as best I can with the hope that someone might have an
idea as to what is causing all these problems.
I've been using gcj for a while (since 3.3 I think) but every so often
strange NPEs pop up in the compiled app.
My app uses Eclipse's SWT 3. (jni: compiled with -fjni)
NullPointerExceptions seem to come out of nowhere, especially since I
added the 'Browser' SWT widget to my app (OLE embedded IE). These
NPE's are due to EXCEPTION_ACCESS_VIOLATIONS, because when I comment
out the line (as suggest by bryce) in win32.cc/win32_exception_handler
that throws the NPE's, the app will instead crash with a windows popup
rather than an NPE:
The instruction at "0x77f623cf" referenced memory at "0x77f5166a". The
memory could not be "written".
The NPE looks like this:
java.lang.NullPointerException
at 0x0062c9be (E:\datal\gcc\gcc\gcc\libgcc2.c)
at 0x0062ceb2 (E:\datal\gcc\gcc\gcc\libgcc2.c)
at 0x0062cf63 (E:\datal\gcc\gcc\gcc\libgcc2.c)
at 0x0062e27d (E:\datal\gcc\gcc\gcc\libgcc2.c)
at 0x00628b9d (E:\datal\gcc\gcc\gcc\libgcc2.c)
at 0x0064415d (E:\datal\gcc\gcc\gcc\libgcc2.c)
at 0x00612772 (E:\datal\gcc\gcc\gcc\libgcc2.c)
at 0x0068f7a7 (E:\datal\gcc\gcc\gcc\libgcc2.c)
at 0x6606ffde (Unknown Source)
at 0x77e937d4 (Unknown Source)
I've tried 3.4.1 and 3.5 20040730 (experimental), as well as Mohan's
3.4 and 3.5 win32 builds.
I use Mohan's scripts to compile gcj:
Configured with: /datal/gcc/gcc/configure
--prefix=/datal/gcc/build/wingcc --build=i686-pc-cygwin
--host=i686-pc-mingw32 --target=i686-pc-mi ngw32
--enable-languages=c,c++,java --with-gcc --with-gnu-as --with-gnu-ld
--enable-threads=win32 --disable-nls --disable-win32-registry --d
isable-shared --disable-debug --without-newlib --enable-libgcj
--disable-java-awt --without-x --enable-java-gc=boehm
--disable-libgcj-debug --enable-interpreter
--enable-hash-synchronization --enable-sjlj-exceptions
--enable-libgcj-multifile --enable-libgcj-mingw-osapi=ansi Thread
model: win32
gcc version 3.5.0 20040730 (experimental)
When I run the app under gdb (GNU gdb 20040521) the following occurs 4
times while loading (new Display() is one such call that causes it,
but the 4th one seems to coincide exactly with the time at which my
app crashes with the NPE.
The warning is the same each time (different locations on RtlFreeHeap
though).
warning: HEAP[sancho.exe]:
warning: Invalid Address specified to RtlFreeHeap( 00250000, 0022F800 )
Program received signal SIGTRAP, Trace/breakpoint trap.
0x77f767ce in ntdll!DbgUiConnectToDbg () from ntdll.dll
if I do this:
GNU gdb 20040521
(gdb) handle SIGTRAP nostop noprint
Signal Stop Print Pass to program Description
SIGTRAP No No No Trace/breakpoint trap
(gdb) r
Starting program: E:\dev\sancho/sancho.exe -n
warning: HEAP[sancho.exe]:
warning: Invalid Address specified to RtlFreeHeap( 00250000, 0022F800 )
warning: HEAP[sancho.exe]:
warning: Invalid Address specified to RtlFreeHeap( 00250000, 0022F500 )
warning: HEAP[sancho.exe]:
warning: Invalid Address specified to RtlFreeHeap( 00250000, 0022F100 )
warning: HEAP[sancho.exe]:
warning: Invalid Address specified to RtlFreeHeap( 00250000, 0022EE00 )
The app doesn't crash, it just reports those. The same happens if I
let SIGTRAPs stop it and just 'continue' over them (no NPE).
Again, if I run the app outside of gdb, it will crash with the NPE (at
about the same time as the 4th warning from above) This is with 3.4.1
or 3.5 at -O1 or above.
If I compile with 3.5, my app seems to work fine at -O0 on my XP SP1
system, but users that have downloaded the app have reported that it
doesn't start at all on their XP systems. If they set 'Compatibility
Mode' in the icon's properties to 98/ME, it will work, except the tabs
of a CTabFolder (SWT widget) are not drawn. (This happens to me as
well in 98/ME mode)
There are no NPEs for them in 95/ME mode and the app does run.
If I set Compatibility Mode to Win2000 or NT4, there is a 'Fatal Error
in gc' popup, 'Too many root sets'.
The exception Breakpoint
A breakpoint has been reached.
(0x80000003) occurred in the application at location 0x77f767cd.
I'm not sure why all of this is occuring or how to go about debugging
it since it does start on my XP system. Compiling with -O1 or above
will cause the NPE on my own system with the 3.5 compiler. (I can get
the NPE to pop up by doing two different things - one of which is to
switch to the tab with the Browser, the other is typing into a
StyledText widget -- but I assume the problem is deeper than this
since this works fine in sun's java).
Needless to say, this app has always worked completely well under
Sun's JDK on my and other systems.
Does anyone have any idea why all of this is occurring? Are there
serious bugs in gcj-win32 and jni code? Is memory being overwritten
somehow? I'm not sure how to even go about understanding or debugging
this.
I don't seem to have any similar experiences when compiling the app on
linux.
I'd appreciate any guidance. Thanks.
And here are the backtraces of all the threads. App was compiled with -g.
(gdb) bt
#0 0x77f767ce in ntdll!DbgUiConnectToDbg () from ntdll.dll
#1 0x77fa2612 in ntdll!RtlpNtMakeTemporaryKey () from ntdll.dll
#2 0x77f881c0 in ntdll!RtlCheckRegistryKey () from ntdll.dll
#3 0x00250000 in ?? ()
#4 0x0022f800 in ?? ()
#5 0x0022f63c in ?? ()
#6 0x77fa2f17 in ntdll!RtlpNtMakeTemporaryKey () from ntdll.dll
#7 0x00250000 in ?? ()
#8 0x0022f7f8 in ?? ()
#9 0x77fb1bd4 in wcstombs () from ntdll.dll
Previous frame inner to this frame (corrupt stack?)
[Switching to thread 2 (thread 1732.0x594)]#0 0x7ffe0304 in ?? ()
(gdb) bt
#0 0x7ffe0304 in ?? ()
#1 0x77f7670b in ntdll!ZwWaitForMultipleObjects () from ntdll.dll
#2 0x77e75ee0 in WaitForMultipleObjectsEx ()
from C:\WINDOWS\system32\kernel32.dll
#3 0x00000003 in ?? ()
#4 0x01c2fd88 in ?? ()
#5 0x00000001 in ?? ()
#6 0x00000000 in ?? () from
#7 0x00000000 in ?? () from
#8 0x01c4ef9c in ?? ()
#9 0x01c4efa4 in ?? ()
#10 0x00000000 in ?? () from
#11 0x00610ea5 in _Unwind_SjLj_Unregister (fc=0x3)
at /datal/gcc/gcc/gcc/gthr-win32.h:531
#12 0x77e75faa in WaitForMultipleObjects ()
from C:\WINDOWS\system32\kernel32.dll
[Switching to thread 3 (thread 1732.0x2c0)]#0 0x7ffe0304 in ?? ()
(gdb) bt
#0 0x7ffe0304 in ?? ()
#1 0x77f762b7 in ntdll!ZwReplyWaitReceivePortEx () from ntdll.dll
#2 0x780016a4 in ntdll!NtAccessCheckByTypeResultListAndAuditAlarm ()
from C:\WINDOWS\system32\rpcrt4.dll
#3 0x0000072c in ?? ()
#4 0x0290ff80 in ?? ()
#5 0x00000000 in ?? () from
[Switching to thread 4 (thread 1732.0x780)]#0 0x7ffe0304 in ?? ()
(gdb) bt
#0 0x7ffe0304 in ?? ()
#1 0x77f7670b in ntdll!ZwWaitForMultipleObjects () from ntdll.dll
#2 0x77e75ee0 in WaitForMultipleObjectsEx ()
from C:\WINDOWS\system32\kernel32.dll
#3 0x00000003 in ?? ()
#4 0x02edfcb8 in ?? ()
[Switching to thread 5 (thread 1732.0x2e0)]#0 0x7ffe0304 in ?? ()
(gdb) bt
#0 0x7ffe0304 in ?? ()
#1 0x77f762b7 in ntdll!ZwReplyWaitReceivePortEx () from ntdll.dll
#2 0x780016a4 in ntdll!NtAccessCheckByTypeResultListAndAuditAlarm ()
from C:\WINDOWS\system32\rpcrt4.dll
#3 0x0000072c in ?? ()
#4 0x03cbff80 in ?? ()
#5 0x00000000 in ?? () from
#6 0x00294e58 in ?? ()
[Switching to thread 6 (thread 1732.0x6a0)]#0 0x7ffe0304 in ?? ()
(gdb) bt
#0 0x7ffe0304 in ?? ()
#1 0x77f75ab4 in ntdll!ZwDelayExecution () from ntdll.dll
#2 0x77e7a37a in SleepEx () from C:\WINDOWS\system32\kernel32.dll
#3 0x00000000 in ?? () from
#4 0x03ebff44 in ?? ()
#5 0x77e7a5a2 in KERNEL32!CreateFileMappingA ()
from C:\WINDOWS\system32\kernel32.dll
#6 0x77e61bf5 in Sleep () from C:\WINDOWS\system32\kernel32.dll
More information about the Java
mailing list