This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Natively compiled SWT segfaults under Windows
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Olivier Parisy wrote:
[...]
> With /Oy-:
> _Java_org_eclipse_swt_internal_win32_OS_AbortDoc@12:
> 55 push ebp
> 8b ec mov ebp,esp
[...]
>> If you need to unwind through a function in a DLL and get the stack
>> trace, you need to compile the DLL with frame pointers enabled. (Even
>> then the current code is quite kludgy - it assumes that the initial
>> part of a function prologue is a sequence of "PUSH ebp; MOV ebp, esp"
>> instructions which might not be true for other compilers or even GCC
>> under "different" circumstances.)
>
> Considering the disassembled code above, this hypothesis looks rather
> robust.
No. Look at the opcodes for the instructions comprising the
prologue - it's "0x55 0x8B 0xEC" instead of the "0x55 0x89 0xE5"
assumed by the code. Both represent "PUSH ebp; MOV ebp, esp", but
the encoding used is different. See:
http://sandpile.org/ia32/index.htm
for reference.
If you want to continue with the existing kludge, you can modify
"libjava/sysdep/i386/backtrace.h" like so:
- ------------------------- 8< -------------------------
- --- backtrace.h.orig Fri Aug 18 11:50:51 2006
+++ backtrace.h Fri Aug 18 11:53:01 2006
@@ -84,6 +84,7 @@
{
unsigned char *scan_bytes = (unsigned char *)scan_addr;
- - if (scan_bytes[0] == 0x55 && scan_bytes[1] == 0x89
- - && scan_bytes[2] == 0xE5)
+ if (scan_bytes[0] == 0x55
+ && ((scan_bytes[1] == 0x89 && scan_bytes[2] == 0xE5)
+ || (scan_bytes[1] == 0x8B && scan_bytes[2] == 0xEC)))
{
ctx.meth_addr = scan_addr;
- ------------------------- 8< -------------------------
recompile libjava and see if it fixes your problem.
A "proper" solution would be to use a prologue analyser like
that used in GDB:
http://sources.redhat.com/gdb/onlinedocs/gdbint_3.html#SEC8
but that is too much work for too little a gain.
HTH,
Ranjit.
- --
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://rmathew.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFE5V6ZYb1hx2wRS48RAlCEAJ9ff92vBb6HWt+fVUzfCat/ja16LgCbB9m5
nll5FpLtHgWX4e7U4r/nzi0=
=RHbM
-----END PGP SIGNATURE-----