http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221
Bug #: 52221 Summary: [libffi] r184021 needs to be fixed. Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libffi AssignedTo: unassig...@gcc.gnu.org ReportedBy: jojel...@gmail.com Host: i686-pc-cygwin Target: i686-pc-mingw32 Build: i686-pc-cygwin tried libjava with r184135, but got SIGSEGV because of following. in libffi/src/x86/ffi.c, #define FFI_INIT_TRAMPOLINE_THISCALL(TRAMP,FUN,CTX,SIZE) \ { unsigned char *__tramp = (unsigned char*)(TRAMP); \ unsigned int __fun = (unsigned int)(FUN); \ unsigned int __ctx = (unsigned int)(CTX); \ unsigned int __dis = __fun - (__ctx + 22); \ ^^^^ 49 and fixing above didn't succeed ExtraClassLoader testcase Starting program: /tmp/gcc/i686-pc-mingw32/libjava/testsuite/ExtraClassLoader [New Thread 412.0xa24] [New Thread 412.0x1398] Program received signal SIGSEGV, Segmentation fault. 0x696c8140 in java::lang::Class* java::lang::Object::getClass() () from /cygdrive/d/cygwin/tmp/gcc/i686-pc-mingw32/libjava/.libs/libgcj-13.dll (gdb) i r eax 0xe 0xe ecx 0x8df4458b 0x8df4458b edx 0x22f9c4 0x22f9c4 ebx 0x1 0x1 esp 0x22f9c4 0x22f9c4 ebp 0x22f9c8 0x22f9c8 esi 0xc01b24 0xc01b24 edi 0xc01b3c 0xc01b3c eip 0x696c8140 0x696c8140 <java::lang::Class* java::lang::Object::getClass()> eflags 0x10202 [ IF RF ] cs 0x1b 0x1b ss 0x23 0x23 ds 0x23 0x23 es 0x23 0x23 fs 0x3b 0x3b gs 0x0 0x0 (gdb) set height 1000 (gdb) bt #0 0x696c8140 in java::lang::Class* java::lang::Object::getClass() () from /cygdrive/d/cygwin/tmp/gcc/i686-pc-mingw32/libjava/.libs/libgcj-13.dll #1 0x69ce1735 in ffi_call_win32 () at ../.././libffi/src/x86/win32.S:464 #2 0x69ce1608 in ffi_raw_call (cif=0xc01b24, fn=0x696c8140 <java::lang::Class* java::lang::Object::getClass()>, rvalue=0x22fbe8, fake_avalue=0x22fa54) at ../.././libffi/src/x86/ffi.c:832 #3 0x6969bd0e in _Jv_InterpMethod::run (retp=0x22fd50, args=0x22fd70, meth=0xac9e10) at ../.././libjava/interpret-run.cc:611 #4 0x69ce1905 in ffi_closure_raw_SYSV () at ../.././libffi/src/x86/win32.S:749 #5 0x00fa0039 in ?? () #6 0x004087bf in ExtraClassLoader.main(java.lang.String[])void () at ExtraClassLoader.java:9 #7 0x696bd642 in gnu::java::lang::MainThread::call_main (this=0xc0ef60) at ../.././libjava/gnu/java/lang/natMainThread.cc:54 #8 0x696fa4d6 in gnu.java.lang.MainThread.run()void (this=@c0ef60) at /tmp/gcc/libjava/gnu/java/lang/MainThread.java:106 #9 0x696cc062 in _Jv_ThreadRun (thread=0xc0ef60) at ../.././libjava/java/lang/natThread.cc:335 #10 0x69683f5d in _Jv_RunMain (vm_args=0x0, klass=klass@entry=0x40a160, name=name@entry=0x0, argc=argc@entry=0x1, argv=argv@entry=0x3d8958, is_jar=is_jar@entry=0x0) at ../.././libjava/prims.cc:1795 #11 0x69684156 in _Jv_RunMain (klass=klass@entry=0x40a160, name=name@entry=0x0, argc=argc@entry=0x1, argv=argv@entry=0x3d8958, is_jar=is_jar@entry=0x0) at ../.././libjava/prims.cc:1820 #12 0x696841bf in JvRunMain (klass=0x40a160, argc=0x1, argv=0x3d8958) at ../.././libjava/prims.cc:1826 #13 0x00401402 in _fu0___Jv_Compiler_Properties () at /tmp/cckDh2w0.i:11 #14 0x004010fd in __mingw_CRTStartup () at ../../.././winsup/mingw/crt1.c:244 #15 0x00000408 in ?? () #16 0x7ffd7000 in ?? () #17 0x00000000 in ?? () Warning: the current language does not match this frame. (gdb) it seems that thiscall trampoline works correctly. 0x00fa0022 in ?? () 4: $ebx = 0x696c5603 3: $ecx = 0x696c5603 2: $eax = 0xfa0008 1: x/i $eip => 0xfa0022: call 0x69ce18be <ffi_closure_SYSV+190> (gdb) 0x69ce18be in ffi_closure_SYSV () at ../.././libffi/src/x86/win32.S:715 715 ret 4: $ebx = 0x696c5603 3: $ecx = 0x696c5603 2: $eax = 0xfa0008 1: x/i $eip => 0x69ce18be <ffi_closure_SYSV+190>: jbe 0x69ce18c0 <ffi_closure_raw_SYSV> (gdb) si ffi_closure_raw_SYSV () at ../.././libffi/src/x86/win32.S:734 734 pushl %ebp 4: $ebx = 0x696c5603 3: $ecx = 0x696c5603 2: $eax = 0xfa0008 1: x/i $eip => 0x69ce18c0 <ffi_closure_raw_SYSV>: push %ebp (gdb) b ffi_call_win32 Breakpoint 4 at 0x69ce16e3: file ../.././libffi/src/x86/win32.S, line 433. (gdb) c Continuing. Breakpoint 4, ffi_call_win32 () at ../.././libffi/src/x86/win32.S:433 433 movl 20(%ebp),%ecx 4: $ebx = 0x1 3: $ecx = 0xe 2: $eax = 0x22fa0c 1: x/i $eip => 0x69ce16e3 <ffi_call_win32+3>: mov 0x14(%ebp),%ecx (gdb) bt #0 ffi_call_win32 () at ../.././libffi/src/x86/win32.S:433 #1 0x69ce15e8 in ffi_raw_call (cif=0xc01bec, fn= 0x696d4940 <java.lang.Object.Object()>, rvalue=0x22fbf0, fake_avalue=0x22fa58) at ../.././libffi/src/x86/ffi.c:827 #2 0x6969bd0e in _Jv_InterpMethod::run (retp=0x22fd58, args=0x22fd78, meth=0xac9e10) at ../.././libjava/interpret-run.cc:611 #3 0x69ce18e5 in ffi_closure_raw_SYSV () at ../.././libffi/src/x86/win32.S:749 #4 0x00fa0027 in ?? () #5 0x004087bf in ExtraClassLoader.main(java.lang.String[])void () at ExtraClassLoader.java:9 #6 0x696bd642 in gnu::java::lang::MainThread::call_main (this=0xc0ef60) at ../.././libjava/gnu/java/lang/natMainThread.cc:54 #7 0x696fa4d6 in gnu.java.lang.MainThread.run()void (this=@c0ef60) at /tmp/gcc/libjava/gnu/java/lang/MainThread.java:106 #8 0x696cc062 in _Jv_ThreadRun (thread=0xc0ef60) at ../.././libjava/java/lang/natThread.cc:335 #9 0x69683f5d in _Jv_RunMain (vm_args=0x0, klass=klass@entry=0x40a160, name=name@entry=0x0, argc=argc@entry=0x1, argv=argv@entry=0x3d8958, is_jar=is_jar@entry=0x0) at ../.././libjava/prims.cc:1795 #10 0x69684156 in _Jv_RunMain (klass=klass@entry=0x40a160, name=name@entry=0x0, argc=argc@entry=0x1, argv=argv@entry=0x3d8958, is_jar=is_jar@entry=0x0) at ../.././libjava/prims.cc:1820 #11 0x696841bf in JvRunMain (klass=0x40a160, argc=0x1, argv=0x3d8958) at ../.././libjava/prims.cc:1826 #12 0x00401402 in _fu0___Jv_Compiler_Properties () at /tmp/cckDh2w0.i:11 #13 0x004010fd in __mingw_CRTStartup () at ../../.././winsup/mingw/crt1.c:244 #14 0x00000408 in ?? () #15 0x7ffdd000 in ?? () #16 0x00000000 in ?? () (gdb) ni ffi_prep_args (stack=0x22f9cc "\032", ecif=0x22fa0c) at ../.././libffi/src/x86/ffi.c:46 warning: Source file is more recent than executable. 46 { 4: $ebx = 0x1 3: $ecx = 0x4 2: $eax = 0x22f9cc 1: x/i $eip => 0x69ce0eb0 <ffi_prep_args>: push %ebp (gdb) finish Run till exit from #0 ffi_prep_args (stack=0x22f9cc "\032", ecif=0x22fa0c) at ../.././libffi/src/x86/ffi.c:46 ffi_call_win32 () at ../.././libffi/src/x86/win32.S:444 444 addl $8,%esp 4: $ebx = 0x1 3: $ecx = 0x1 2: $eax = 0xe 1: x/i $eip => 0x69ce16f1 <ffi_call_win32+17>: add $0x8,%esp (gdb) ni 447 cmpl $3, 16(%ebp) # FFI_THISCALL 4: $ebx = 0x1 3: $ecx = 0x1 2: $eax = 0xe 1: x/i $eip => 0x69ce16f4 <ffi_call_win32+20>: cmpl $0x3,0x10(%ebp) (gdb) 448 jz .do_thiscall 4: $ebx = 0x1 3: $ecx = 0x1 2: $eax = 0xe 1: x/i $eip => 0x69ce16f8 <ffi_call_win32+24>: je 0x69ce170c <ffi_call_win32+44> (gdb) 456 movl (%esp), %ecx 4: $ebx = 0x1 3: $ecx = 0x1 2: $eax = 0xe 1: x/i $eip => 0x69ce170c <ffi_call_win32+44>: mov (%esp),%ecx (gdb) x $esp 0x22f9cc: 0x8df4458b parameter is broken for sure. please check ffi_prep_args