bad news re: mingw exceptions
Adam Megacz
gcj@lists.megacz.com
Thu Feb 28 14:42:00 GMT 2002
Bryce McKinlay <bryce@waitaki.otago.ac.nz> writes:
> > At compile time, how does g++ know that test.cc will get linked
> > against Java code later on (and hence should emit code for Java
> > exceptions, not C++ exceptions)?
> #pragma gcc java_exceptions
Interestingly, when I add this line to test.cc, I am able to link
without -lsupc++. When I do *not* add this line, I must link -lsupc++.
This would seem to indicate that the code I posted earlier was using
C++ exceptions in the CNI case.
However, even when I enable this pragma and do *not* link supc++
(which means that I am *definately* using Java exceptions), the
program runs properly.
> This is declared in some header which is #included from all the CNI
> headers.
Yes, it's pulled in by javaprims.h, but not by cni.h. Is that how it's
supposed to work?
> If its missing __g++_eh_personality or some such symbol, you're using
Yeah, that was it, but as I mentioned earlier in this message, it's
moot since even with pragma java_exceptions, exceptions written in C++
work. Very strange, huh?
> My first suspect would be the builtins patch.
Can you give me a pointer to more info on this? I'll roll my source
tree back to before the patch was applied and try again.
> Could you compile your minimal test case with "-O2 -S -fverbose-asm" and
> post the resulting .s file?
Thanks a lot for taking the time to look at this.
The program below segfaults in _Unwind_SjLj_RaiseException (as a
result of calling _Jv_Throw()). The disassembly for that function
contains only two CALLs, one of which is to a fixed address, and the
other to the value in ecx. The latter call is where it segfaults;
presumably jumping to an invalid location.
- a
______________________________________________________________________________
Java:
public class test3 {
public static void main(String[] s) {
try {
throw new Exception();
} catch (Exception e) {
}
}
}
______________________________________________________________________________
ASM [gcj -c test3.java -O2 -S -fverbose-asm -o test3.s]
.file "test3.java"
# GNU Java version 3.2 20020227 (experimental) (i686-pc-mingw32)
# compiled by GNU C version 2.95.4 20011006 (Debian prerelease).
# options passed: -fno-use-divide-subroutine -fuse-boehm-gc
# -fnon-call-exceptions -fkeep-inline-functions -O2 -fverbose-asm
# options enabled: -fdefer-pop -foptimize-sibling-calls
# -fcse-follow-jumps -fcse-skip-blocks -fexpensive-optimizations
# -fthread-jumps -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse
# -fkeep-inline-functions -finline -fkeep-static-consts -fcaller-saves
# -freg-struct-return -fgcse -fgcse-lm -fgcse-sm -frerun-cse-after-loop
# -frerun-loop-opt -fdelete-null-pointer-checks -fschedule-insns2
# -fsched-interblock -fsched-spec -fbranch-count-reg -fexceptions
# -funwind-tables -fasynchronous-unwind-tables -fnon-call-exceptions
# -freorder-blocks -fcprop-registers -fcommon -fverbose-asm -fgnu-linker
# -fregmove -foptimize-register-move -fargument-alias -fstrict-aliasing
# -fmerge-constants -fident -fpeephole2 -fguess-branch-probability
# -fmath-errno -ftrapping-math -fbounds-check -m80387 -mhard-float
# -mno-soft-float -mieee-fp -mfp-ret-in-387 -mstack-arg-probe
# -mcpu=pentiumpro -march=i386
.text
.align 2
.p2align 4,,15
.globl __ZN5test3C1Ev
.def __ZN5test3C1Ev; .scl 2; .type 32; .endef
__ZN5test3C1Ev:
LFB1:
pushl %ebp
LCFI0:
movl %esp, %ebp
LCFI1:
subl 8,ドル %esp
LCFI2:
movl %ebp, %esp
popl %ebp
jmp __ZN4java4lang6ObjectC1Ev
LFE1:
.def __Unwind_SjLj_Resume; .scl 2; .type 32; .endef
.def ___gcj_personality_sj0; .scl 2; .type 32; .endef
.def __Unwind_SjLj_Register; .scl 2; .type 32; .endef
.def __Unwind_SjLj_Unregister; .scl 2; .type 32; .endef
.align 2
.p2align 4,,15
.globl __ZN5test34mainEP6JArrayIPN4java4lang6StringEE
.def __ZN5test34mainEP6JArrayIPN4java4lang6StringEE; .scl 2; .type 32; .endef
__ZN5test34mainEP6JArrayIPN4java4lang6StringEE:
LFB2:
pushl %ebp
LCFI3:
movl %esp, %ebp
LCFI4:
subl 88,ドル %esp
LCFI5:
movl %esp, -16(%ebp)
leal -12(%ebp), %eax
movl %eax, -24(%ebp)
leal -56(%ebp), %eax
movl %eax, (%esp)
movl %ebx, -12(%ebp)
LCFI6:
movl %esi, -8(%ebp)
LCFI7:
movl %edi, -4(%ebp)
LCFI8:
movl $___gcj_personality_sj0, -32(%ebp)
movl $LLSDA0, -28(%ebp)
movl $L6, -20(%ebp)
call __Unwind_SjLj_Register
movl $__ZN5test36class$E, (%esp)
movl $-1, -52(%ebp)
call __Jv_InitClass
movl $__ZN4java4lang9Exception6class$E, (%esp)
movl 16,ドル 4(%esp)
movl 1,ドル -52(%ebp)
call __Jv_AllocObjectNoFinalizer
movl %eax, -60(%ebp)
movl %eax, (%esp)
call __ZN4java4lang9ExceptionC1Ev
movl -60(%ebp), %eax
movl %eax, (%esp)
call __Jv_Throw
.p2align 4,,7
L6:
addl 12,ドル %ebp
cmpl 1,ドル -44(%ebp)
movl -48(%ebp), %eax
jne L7
L1:
movl $-1, -52(%ebp)
leal -56(%ebp), %eax
movl %eax, (%esp)
call __Unwind_SjLj_Unregister
movl -4(%ebp), %edi
movl -12(%ebp), %ebx
movl -8(%ebp), %esi
movl %ebp, %esp
popl %ebp
ret
L7:
movl %eax, (%esp)
movl $-1, -52(%ebp)
call __Unwind_SjLj_Resume
LFE2:
.section .gcc_except_table,"w"
.align 4
LLSDA0:
.byte 0xff
.byte 0x0
.uleb128 LLSDATT0-LLSDATTD0
LLSDATTD0:
.byte 0x1
.uleb128 LLSDACSE0-LLSDACSB0
LLSDACSB0:
.uleb128 0x0
.uleb128 0x1
LLSDACSE0:
.byte 0x1
.byte 0x0
.align 4
.long __ZN4java4lang9Exception6class$E
LLSDATT0:
.text
.align 2
__Utf1:
.word 1465
.word 4
.ascii "main"
.space 1
.align 2
__Utf2:
.word 59434
.word 22
.ascii "([Ljava.lang.String;)V"
.space 1
.align 2
__Utf3:
.word 626
.word 6
.ascii "<init>"
.space 1
.align 2
__Utf4:
.word 39797
.word 3
.ascii "()V"
.space 1
.data
.align 32
__MT_test3:
.long __Utf1
.long __Utf2
.word 16393
.word -1
.long __ZN5test34mainEP6JArrayIPN4java4lang6StringEE
.long 0
.long __Utf3
.long __Utf4
.word 16385
.word -1
.long __ZN5test3C1Ev
.long 0
.globl __ZTVN5test3E
.align 32
__ZTVN5test3E:
.long 0
.long 0
.long __ZN5test36class$E
.long 8
.long __ZN4java4lang6Object8finalizeEv
.long __ZN4java4lang6Object8hashCodeEv
.long __ZN4java4lang6Object6equalsEPS1_
.long __ZN4java4lang6Object8toStringEv
.long __ZN4java4lang6Object5cloneEv
.text
.align 2
__Utf5:
.word 19937
.word 5
.ascii "test3"
.space 1
.globl __ZN5test36class$E
.data
.align 32
__ZN5test36class$E:
.long __ZTVN4java4lang5ClassE+8
.long 0
.long 0
.long __Utf5
.word 1
.space 2
.long __ZN4java4lang6Object6class$E
.long 0
.long 0
.long 0
.long __MT_test3
.word 2
.word 5
.long 0
.long 8
.word 0
.word 0
.long __ZTVN5test3E+8
.long 0
.long 0
.long 0
.long 0
.word 0
.byte 0
.space 1
.long 0
.word 0
.space 2
.long 0
.long 0
.long 0
.long 0
.def __Jv_RegisterClass; .scl 2; .type 32; .endef
.text
.align 2
.p2align 4,,15
.def __GLOBAL__I__ZN5test3C1Ev; .scl 3; .type 32; .endef
__GLOBAL__I__ZN5test3C1Ev:
LFB3:
pushl %ebp
LCFI9:
movl %esp, %ebp
LCFI10:
subl 24,ドル %esp
LCFI11:
movl $__ZN5test36class$E, (%esp)
call __Jv_RegisterClass
movl %ebp, %esp
popl %ebp
ret
LFE3:
.section .ctors,"w"
.align 4
.long __GLOBAL__I__ZN5test3C1Ev
.def __ZN4java4lang6Object5cloneEv; .scl 3; .type 32; .endef
.def __ZN4java4lang6Object8hashCodeEv; .scl 3; .type 32; .endef
.def __Jv_Throw; .scl 3; .type 32; .endef
.def __Jv_AllocObjectNoFinalizer; .scl 3; .type 32; .endef
.def __Jv_InitClass; .scl 3; .type 32; .endef
--
"If I put copyrighted material into the 'chewy nougat center', I can
claim the crunchy chocolate coating is an 'Access Control
Mechanism'." --lynx_user_abroad
Why Windows NT/2k/XP is unreliable: www.zappadoodle.com
More information about the Java
mailing list