public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libffi/52221] New: [libffi] r184021 needs to be fixed.
@ 2012-02-12 17:22 jojelino at gmail dot com
  2012-02-12 17:58 ` [Bug libffi/52221] " ktietz at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: jojelino at gmail dot com @ 2012-02-12 17:22 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: jojelino@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


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
@ 2012-02-12 17:58 ` ktietz at gcc dot gnu.org
  2012-02-13 15:18 ` ktietz at gcc dot gnu.org
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-02-12 17:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-02-12
                 CC|                            |ktietz at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-02-12 17:58:27 UTC ---
Yes, I missed to adjust displacement. Following hunk

@@ -614,7 +614,7 @@
 { unsigned char *__tramp = (unsigned char*)(TRAMP); \
    unsigned int  __fun = (unsigned int)(FUN); \
    unsigned int  __ctx = (unsigned int)(CTX); \
-   unsigned int  __dis = __fun - (__ctx + 22);  \
+   unsigned int  __dis = __fun - (__ctx + 49);  \
    unsigned short __size = (unsigned short)(SIZE); \
    *(unsigned int *) &__tramp[0] = 0x8324048b; /* mov (%esp), %eax */ \
    *(unsigned int *) &__tramp[4] = 0x4c890cec; /* sub $12, %esp */ \

fixes it.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
  2012-02-12 17:58 ` [Bug libffi/52221] " ktietz at gcc dot gnu.org
@ 2012-02-13 15:18 ` ktietz at gcc dot gnu.org
  2012-02-13 15:19 ` ktietz at gcc dot gnu.org
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-02-13 15:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #2 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-02-13 15:18:19 UTC ---
Author: ktietz
Date: Mon Feb 13 15:18:14 2012
New Revision: 184155

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184155
Log:
        PR libffi/52221
        * src/x86/ffi.c (ffi_prep_raw_closure_loc): Add thiscall
        support for X86_WIN32.
        (FFI_INIT_TRAMPOLINE_THISCALL): Fix displacement.

Modified:
    trunk/libffi/ChangeLog
    trunk/libffi/src/x86/ffi.c


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
  2012-02-12 17:58 ` [Bug libffi/52221] " ktietz at gcc dot gnu.org
  2012-02-13 15:18 ` ktietz at gcc dot gnu.org
@ 2012-02-13 15:19 ` ktietz at gcc dot gnu.org
  2012-02-13 17:02 ` jojelino at gmail dot com
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-02-13 15:19 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-02-13 15:18:58 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (2 preceding siblings ...)
  2012-02-13 15:19 ` ktietz at gcc dot gnu.org
@ 2012-02-13 17:02 ` jojelino at gmail dot com
  2012-02-13 18:35 ` jojelino at gmail dot com
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jojelino at gmail dot com @ 2012-02-13 17:02 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

gee <jojelino at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |WAITING
         Resolution|FIXED                       |

--- Comment #4 from gee <jojelino at gmail dot com> 2012-02-13 17:02:18 UTC ---
(In reply to comment #3)
> Fixed.
No. it doesn't fixed. following debug session shows.

(gdb)
0x00fa0008 in ?? ()
(gdb) disp /5w $esp
6: x/5xw $esp
0x22fd7c:       0x696c5603      0x00e20e40      0x00a63fd0      0x00a63ff0
0x22fd8c:       0x00aa9848
(gdb) disp /w $ecx
7: x/xw $ecx  0xaa7e00: 0x00a6dc20
              ^^^^^^^^
                 this parameter
(gdb) ni
0x00fa000b in ?? ()
7: x/xw $ecx  0xaa7e00: 0x00a6dc20
6: x/5xw $esp
0x22fd7c:       0x696c5603      0x00e20e40      0x00a63fd0      0x00a63ff0
0x22fd8c:       0x00aa9848
(gdb) disp /i $eip
8: x/i $eip
=> 0xfa000b:    sub    $0xc,%esp
(gdb) ni
0x00fa000e in ?? ()
8: x/i $eip
=> 0xfa000e:    mov    %ecx,0x4(%esp)
7: x/xw $ecx  0xaa7e00: 0x00a6dc20
6: x/5xw $esp
0x22fd70:       0x00e20e40      0x00ace300      0x0022fda8      0x696c5603
0x22fd80:       0x00e20e40
(gdb)
0x00fa0012 in ?? ()
8: x/i $eip
=> 0xfa0012:    mov    %eax,(%esp)
7: x/xw $ecx  0xaa7e00: 0x00a6dc20
6: x/5xw $esp
0x22fd70:       0x00e20e40      0x00aa7e00      0x0022fda8      0x696c5603
0x22fd80:       0x00e20e40
(gdb)
0x00fa0015 in ?? ()
8: x/i $eip
=> 0xfa0015:    mov    $0x4,%eax
7: x/xw $ecx  0xaa7e00: 0x00a6dc20
6: x/5xw $esp
0x22fd70:       0x696c5603      0x00aa7e00      0x0022fda8      0x696c5603
0x22fd80:       0x00e20e40
(gdb)
0x00fa001a in ?? ()
8: x/i $eip
=> 0xfa001a:    lea    0x8(%esp),%ecx
7: x/xw $ecx  0xaa7e00: 0x00a6dc20
6: x/5xw $esp
0x22fd70:       0x696c5603      0x00aa7e00      0x0022fda8      0x696c5603
0x22fd80:       0x00e20e40
(gdb)
0x00fa001e in ?? ()
8: x/i $eip
=> 0xfa001e:    shr    $0x2,%eax
7: x/xw $ecx  0x22fd78: 0x0022fda8
6: x/5xw $esp
0x22fd70:       0x696c5603      0x00aa7e00      0x0022fda8      0x696c5603
0x22fd80:       0x00e20e40
(gdb)
0x00fa0021 in ?? ()
8: x/i $eip
=> 0xfa0021:    dec    %eax
7: x/xw $ecx  0x22fd78: 0x0022fda8
6: x/5xw $esp
0x22fd70:       0x696c5603      0x00aa7e00      0x0022fda8      0x696c5603
0x22fd80:       0x00e20e40
(gdb)
0x00fa0022 in ?? ()
8: x/i $eip
=> 0xfa0022:    je     0xfa002f
7: x/xw $ecx  0x22fd78: 0x0022fda8
6: x/5xw $esp
0x22fd70:       0x696c5603      0x00aa7e00      0x0022fda8      0x696c5603
0x22fd80:       0x00e20e40
(gdb)
0x00fa002f in ?? ()
8: x/i $eip
=> 0xfa002f:    mov    $0xfa0008,%eax
7: x/xw $ecx  0x22fd78: 0x0022fda8
6: x/5xw $esp
0x22fd70:       0x696c5603      0x00aa7e00      0x0022fda8      0x696c5603
0x22fd80:       0x00e20e40
(gdb)
0x00fa0034 in ?? ()
8: x/i $eip
=> 0xfa0034:    call   0x69ce18e0 <ffi_closure_raw_SYSV>
7: x/xw $ecx  0x22fd78: 0x0022fda8
6: x/5xw $esp
0x22fd70:       0x696c5603      0x00aa7e00      0x0022fda8      0x696c5603
0x22fd80:       0x00e20e40

Kai Tietz, could you explain why return address (0x696c5603) is at top of the
stack? (although it is not first argument for the method? i suspect that you
should have corrected this.)
top of the stack must be 0x00aa7e00, not 0x696c5603.

so it is turned out that thiscall trampoline code was invalid.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (3 preceding siblings ...)
  2012-02-13 17:02 ` jojelino at gmail dot com
@ 2012-02-13 18:35 ` jojelino at gmail dot com
  2012-02-13 21:06 ` ktietz at gcc dot gnu.org
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jojelino at gmail dot com @ 2012-02-13 18:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #5 from gee <jojelino at gmail dot com> 2012-02-13 18:35:18 UTC ---
Created attachment 26653
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26653
proposed patch

sorry for pr51500 attachment 26584, it was very bad idea.
thiscall trampoline uses call insn so it needed to create related stub
function.
i was releutant to create stub function in win32.S and it resulted in disaster.
in this patch these problem is considered.

and thiscall trampoline subs esp and then call fun, this is bad idea. it works
only when #of argument is 1.(passed only this)

already i encountered the problem that are described above.


`/tmp/gcc/i686-pc-mingw32/libjava/.libs/libgcj-13.dll' has changed; re-reading
symbols.
Starting program: /tmp/gcc/i686-pc-mingw32/libjava/testsuite/ExtraClassLoader
[New Thread 5276.0x19bc]

Breakpoint 5, java::lang::Class::newInstance (this=0xe20e40)
    at ../.././libjava/java/lang/natClass.cc:667
667       ((void (__thiscall *) (jobject)) meth->ncode) (r);
(gdb)
Continuing.

Program received signal SIGSEGV, Segmentation fault.
_Jv_GetStringUTFLength (string=0x69e61688)
    at ../.././libjava/java/lang/natString.cc:324
324           jchar ch = *ptr++;

in this case string parameter is wrong.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (4 preceding siblings ...)
  2012-02-13 18:35 ` jojelino at gmail dot com
@ 2012-02-13 21:06 ` ktietz at gcc dot gnu.org
  2012-02-15 21:43 ` [Bug libffi/52221] [libffi] r183675,r184021 " jojelino at gmail dot com
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-02-13 21:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #6 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-02-13 21:05:45 UTC ---
hmm,

would you mind to provide a patch against current gcc's trunk?

Regards,
Kai


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (5 preceding siblings ...)
  2012-02-13 21:06 ` ktietz at gcc dot gnu.org
@ 2012-02-15 21:43 ` jojelino at gmail dot com
  2012-02-16 20:20 ` jojelino at gmail dot com
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jojelino at gmail dot com @ 2012-02-15 21:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

gee <jojelino at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[libffi] r184021 needs to   |[libffi] r183675,r184021
                   |be fixed.                   |needs to be fixed.
           Severity|normal                      |blocker

--- Comment #7 from gee <jojelino at gmail dot com> 2012-02-15 21:32:10 UTC ---
there is an big mistake in r183675

-      ffi_call_win32(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
-                     ecif.rvalue, fn);
+      ffi_call_win32(ffi_prep_args, &ecif, cif->abi, cif->bytes, cif->flags,
+             ecif.rvalue, fn);

and below the mistake, another one.

+    if (passed_regs < 2 && abi == FFI_FASTCALL)
+      abi = FFI_THISCALL;
+    if (passed_regs < 1 && abi == FFI_THISCALL)
+      abi = FFI_STDCALL;
+        ffi_call_win32(ffi_prep_args, &ecif, abi, cif->bytes, cif->flags,
+                       ecif.rvalue, fn);
+      }

why ffi_prep_args_raw changed to ffi_prep_args?? this explains why i succeed
but not sigsegving in ExtraClassLoader.
because of this, i decidec to raise the severity to blocker.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (6 preceding siblings ...)
  2012-02-15 21:43 ` [Bug libffi/52221] [libffi] r183675,r184021 " jojelino at gmail dot com
@ 2012-02-16 20:20 ` jojelino at gmail dot com
  2012-02-16 21:01 ` ktietz at gcc dot gnu.org
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jojelino at gmail dot com @ 2012-02-16 20:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #8 from gee <jojelino at gmail dot com> 2012-02-16 20:12:21 UTC ---
Created attachment 26685
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26685
proposed patch

with this patch, ExtraClassLoader testcase passed with three `true'
testing for whole libjava testsuite.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (7 preceding siblings ...)
  2012-02-16 20:20 ` jojelino at gmail dot com
@ 2012-02-16 21:01 ` ktietz at gcc dot gnu.org
  2012-02-16 21:06 ` jojelino at gmail dot com
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-02-16 21:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #10 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-02-16 20:37:28 UTC ---
I see here three issues about this patch.

First, you don't treat stack-alignment.
Second, why you emulate here stack-argument cleanup for ret __size-4?  Why not
stick to already present variant?
Thirs, you corrupt arguments after the second.

That this patch works for you might be true, but it is for sure in general
wrong.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (8 preceding siblings ...)
  2012-02-16 21:01 ` ktietz at gcc dot gnu.org
@ 2012-02-16 21:06 ` jojelino at gmail dot com
  2012-02-16 23:35 ` jojelino at gmail dot com
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jojelino at gmail dot com @ 2012-02-16 21:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

gee <jojelino at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #26653|0                           |1
        is obsolete|                            |

--- Comment #9 from gee <jojelino at gmail dot com> 2012-02-16 20:19:22 UTC ---
Created attachment 26686
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26686
script used for generating trampoline code.

trampoline code in attachment 26685 based on following source code.

extern int* esp asm ("%esp");
volatile int
sideeffect();
static volatile int ctx;
int __cdecl
main()
{
  int ret;
  extern int ecx asm("%ecx");
  /*
   * CFLAGS -O4
   */
#define NUM_CLOBBERED_REG 1
  /* expected layout
   /* ret   esp[4]
   * ?      esp[3]
   * clobbered
   */
  asm volatile("blk1:");
#define swap(x,y,tmp,...) {\
    asm ("movl %0,%2 # movl x,tmp\n\
    movl %1,%0 # movl y,x\n\
    movl %2,%1 # movl tmp,y":"+g"(x),"+g"(y),"+g"(tmp)::__VA_ARGS__);\
}
  swap(esp[NUM_CLOBBERED_REG+1], ecx, esp[NUM_CLOBBERED_REG], "ecx");
  /* expected layout
   * ecx    esp[4]
   * ret    esp[3]
   * clobbered
   */
  asm ("movl %0,%%eax"::"i"(&ctx):"eax");
  esp -= NUM_CLOBBERED_REG + 1;
  asm volatile ("call _sideeffect":"+a"(ret)::"memory","ecx","edx");
  ecx = esp[NUM_CLOBBERED_REG + 1];
  esp[NUM_CLOBBERED_REG + 1] = esp[NUM_CLOBBERED_REG];

  /* expected layout
   * ret    esp[4]
   * ret    esp[3]
   * clobbered
   */
  esp += NUM_CLOBBERED_REG + 1;
  asm volatile("ret");
  asm volatile("blk2:");
  return ret;
}
volatile int
sideeffect()
{
  return (volatile int) 0;
}


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (9 preceding siblings ...)
  2012-02-16 21:06 ` jojelino at gmail dot com
@ 2012-02-16 23:35 ` jojelino at gmail dot com
  2012-02-17  8:39 ` jojelino at gmail dot com
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jojelino at gmail dot com @ 2012-02-16 23:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #11 from gee <jojelino at gmail dot com> 2012-02-16 23:19:45 UTC ---
(In reply to comment #8)
> Created attachment 26685 [details]
> proposed patch
> 
> with this patch, ExtraClassLoader testcase passed with three `true'
> testing for whole libjava testsuite.

Running /tmp/gcc/libjava/testsuite/libjava.cni/cni.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.jar/jar.exp ...
FAIL: TestClosureGC output
FAIL: libjava.jar/TestClosureGC.jar execution - gij test
FAIL: simple output
FAIL: libjava.jar/simple.jar execution - gij test
Running /tmp/gcc/libjava/testsuite/libjava.jni/jni.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.jvmti/jvmti-interp.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.jvmti/jvmti.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.lang/lang.exp ...
FAIL: ProxyTest -O3 execution - source compiled test
FAIL: ProxyTest -O3 -findirect-dispatch execution - source compiled test
FAIL: StackTrace2 output - source compiled test
FAIL: StackTrace2 -findirect-dispatch output - source compiled test
FAIL: StackTrace2 -O3 output - source compiled test
FAIL: StackTrace2 -O3 -findirect-dispatch output - source compiled test
FAIL: TestProxy -O3 execution - source compiled test
FAIL: TestProxy -O3 -findirect-dispatch execution - source compiled test
FAIL: Thread_Sleep output - source compiled test
FAIL: Thread_Sleep -findirect-dispatch output - source compiled test
FAIL: Thread_Sleep -O3 output - source compiled test
FAIL: Thread_Sleep_2 output - source compiled test
FAIL: Thread_Sleep_2 -findirect-dispatch output - source compiled test
FAIL: Thread_Sleep_2 -O3 output - source compiled test
FAIL: Thread_Sleep_2 -O3 -findirect-dispatch output - source compiled test
FAIL: md5test execution - source compiled test
FAIL: md5test -findirect-dispatch execution - source compiled test
FAIL: md5test -O3 execution - source compiled test
FAIL: md5test -O3 -findirect-dispatch execution - source compiled test
FAIL: pr21785 execution - source compiled test
FAIL: pr21785 -findirect-dispatch execution - source compiled test
FAIL: pr21785 -O3 execution - source compiled test
FAIL: pr21785 -O3 -findirect-dispatch execution - source compiled test
FAIL: pr26990 execution - source compiled test
FAIL: pr26990 -findirect-dispatch execution - source compiled test
FAIL: pr26990 -O3 execution - source compiled test
FAIL: pr26990 -O3 -findirect-dispatch execution - source compiled test
FAIL: shatest execution - source compiled test
FAIL: shatest -findirect-dispatch execution - source compiled test
FAIL: shatest -O3 execution - source compiled test
FAIL: shatest -O3 -findirect-dispatch execution - source compiled test
Running /tmp/gcc/libjava/testsuite/libjava.loader/loader.exp ...
FAIL: TestMultiple output - source compiled test
FAIL: TestParent output - source compiled test
Running /tmp/gcc/libjava/testsuite/libjava.mauve/mauve.exp ...
sh: /configure: No such file or directory
FAIL: Mauve configure
Running /tmp/gcc/libjava/testsuite/libjava.special/special.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.verify/verify.exp ...


md5test~shatest has dependency to pr51901.

there is no sigsegv except TestProxy,ProxyTest
in pr52051 it was described


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (10 preceding siblings ...)
  2012-02-16 23:35 ` jojelino at gmail dot com
@ 2012-02-17  8:39 ` jojelino at gmail dot com
  2012-02-17  9:07 ` ktietz at gcc dot gnu.org
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jojelino at gmail dot com @ 2012-02-17  8:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #12 from gee <jojelino at gmail dot com> 2012-02-17 08:38:01 UTC ---
Created attachment 26692
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26692
proposed patch without trampoline diff

(In reply to comment #10)
> I see here three issues about this patch.
> 
> First, you don't treat stack-alignment.
> Second, why you emulate here stack-argument cleanup for ret __size-4?  Why not
> stick to already present variant?
> Thirs, you corrupt arguments after the second.
> 
yes. sorry for unnecessary trampoline diff. does this patch solves the issues?


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (11 preceding siblings ...)
  2012-02-17  8:39 ` jojelino at gmail dot com
@ 2012-02-17  9:07 ` ktietz at gcc dot gnu.org
  2012-02-22 18:23 ` jojelino at gmail dot com
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-02-17  9:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #13 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-02-17 09:03:02 UTC ---
Yes, this looks better IMHO.  Btw any differences about libjava testsuite run
about this altered libffi patch?


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (12 preceding siblings ...)
  2012-02-17  9:07 ` ktietz at gcc dot gnu.org
@ 2012-02-22 18:23 ` jojelino at gmail dot com
  2012-02-23 21:04 ` ktietz at gcc dot gnu.org
  2012-02-23 21:28 ` ktietz at gcc dot gnu.org
  15 siblings, 0 replies; 17+ messages in thread
From: jojelino at gmail dot com @ 2012-02-22 18:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #14 from gee <jojelino at gmail dot com> 2012-02-22 18:13:35 UTC ---
(In reply to comment #13)
> Yes, this looks better IMHO.  Btw any differences about libjava testsuite run
> about this altered libffi patch?

WARNING: Couldn't find the global config file.
Test Run By Administrator on Thu Feb 23 01:18:02 2012
Target is i686-pc-mingw32
Host   is i686-pc-mingw32
Build  is i686-pc-cygwin

                === libjava tests ===

Schedule of variations:
    unix

Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for
target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using /tmp/gcc/libjava/testsuite/config/default.exp as tool-and-target-specific
interface file.
WARNING: Assuming target board is the local machine (which is probably wrong).
You may need to set your DEJAGNU environment variable.
Running /tmp/gcc/libjava/testsuite/libjava.cni/cni.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.jar/jar.exp ...
FAIL: TestClosureGC output
FAIL: libjava.jar/TestClosureGC.jar execution - gij test
FAIL: simple output
FAIL: libjava.jar/simple.jar execution - gij test
Running /tmp/gcc/libjava/testsuite/libjava.jni/jni.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.jvmti/jvmti-interp.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.jvmti/jvmti.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.lang/lang.exp ...
FAIL: StackTrace2 output - source compiled test
FAIL: StackTrace2 -findirect-dispatch output - source compiled test
FAIL: StackTrace2 -O3 output - source compiled test
FAIL: StackTrace2 -O3 -findirect-dispatch output - source compiled test
FAIL: Thread_Sleep output - source compiled test
FAIL: Thread_Sleep_2 output - source compiled test
FAIL: Thread_Sleep_2 -findirect-dispatch output - source compiled test
FAIL: Thread_Sleep_2 -O3 output - source compiled test
FAIL: Thread_Sleep_2 -O3 -findirect-dispatch output - source compiled test
FAIL: md5test execution - source compiled test
FAIL: md5test -findirect-dispatch execution - source compiled test
FAIL: md5test -O3 execution - source compiled test
FAIL: md5test -O3 -findirect-dispatch execution - source compiled test
FAIL: pr21785 execution - source compiled test
FAIL: pr21785 -findirect-dispatch execution - source compiled test
FAIL: pr21785 -O3 execution - source compiled test
FAIL: pr21785 -O3 -findirect-dispatch execution - source compiled test
FAIL: pr26990 execution - source compiled test
FAIL: pr26990 -findirect-dispatch execution - source compiled test
FAIL: pr26990 -O3 execution - source compiled test
FAIL: pr26990 -O3 -findirect-dispatch execution - source compiled test
FAIL: shatest execution - source compiled test
FAIL: shatest -findirect-dispatch execution - source compiled test
FAIL: shatest -O3 execution - source compiled test
FAIL: shatest -O3 -findirect-dispatch execution - source compiled test
Running /tmp/gcc/libjava/testsuite/libjava.loader/loader.exp ...
FAIL: TestMultiple output - source compiled test
FAIL: TestParent output - source compiled test
Running /tmp/gcc/libjava/testsuite/libjava.mauve/mauve.exp ...
sh: /configure: No such file or directory
FAIL: Mauve configure
Running /tmp/gcc/libjava/testsuite/libjava.special/special.exp ...
Running /tmp/gcc/libjava/testsuite/libjava.verify/verify.exp ...

                === libjava Summary ===

# of expected passes            2360
# of unexpected failures        32
# of untested testcases         18
Makefile:385: recipe for target `check-DEJAGNU' failed
make[1]: *** [check-DEJAGNU] Error 1
make[1]: Leaving directory `/tmp/gcc/i686-pc-mingw32/libjava/testsuite'
Makefile:409: recipe for target `check-am' failed
make: *** [check-am] Error 2

no problem with attachment 26692. please apply this.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (13 preceding siblings ...)
  2012-02-22 18:23 ` jojelino at gmail dot com
@ 2012-02-23 21:04 ` ktietz at gcc dot gnu.org
  2012-02-23 21:28 ` ktietz at gcc dot gnu.org
  15 siblings, 0 replies; 17+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-02-23 21:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

--- Comment #15 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-02-23 21:02:32 UTC ---
Author: ktietz
Date: Thu Feb 23 21:02:27 2012
New Revision: 184526

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184526
Log:
        PR libffi/52221
        * src/x86/ffi.c (ffi_closure_raw_THISCALL): New
        prototype.
        (ffi_prep_raw_closure_loc): Use ffi_closure_raw_THISCALL for
        thiscall-convention.
        (ffi_raw_call): Use ffi_prep_args_raw.
        * src/x86/win32.S (ffi_closure_raw_THISCALL): Add
        implementation for stub.


Modified:
    trunk/libffi/ChangeLog
    trunk/libffi/src/x86/ffi.c
    trunk/libffi/src/x86/win32.S


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug libffi/52221] [libffi] r183675,r184021 needs to be fixed.
  2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
                   ` (14 preceding siblings ...)
  2012-02-23 21:04 ` ktietz at gcc dot gnu.org
@ 2012-02-23 21:28 ` ktietz at gcc dot gnu.org
  15 siblings, 0 replies; 17+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-02-23 21:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52221

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED

--- Comment #16 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-02-23 21:03:44 UTC ---
Fixed


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-02-23 21:04 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-12 17:22 [Bug libffi/52221] New: [libffi] r184021 needs to be fixed jojelino at gmail dot com
2012-02-12 17:58 ` [Bug libffi/52221] " ktietz at gcc dot gnu.org
2012-02-13 15:18 ` ktietz at gcc dot gnu.org
2012-02-13 15:19 ` ktietz at gcc dot gnu.org
2012-02-13 17:02 ` jojelino at gmail dot com
2012-02-13 18:35 ` jojelino at gmail dot com
2012-02-13 21:06 ` ktietz at gcc dot gnu.org
2012-02-15 21:43 ` [Bug libffi/52221] [libffi] r183675,r184021 " jojelino at gmail dot com
2012-02-16 20:20 ` jojelino at gmail dot com
2012-02-16 21:01 ` ktietz at gcc dot gnu.org
2012-02-16 21:06 ` jojelino at gmail dot com
2012-02-16 23:35 ` jojelino at gmail dot com
2012-02-17  8:39 ` jojelino at gmail dot com
2012-02-17  9:07 ` ktietz at gcc dot gnu.org
2012-02-22 18:23 ` jojelino at gmail dot com
2012-02-23 21:04 ` ktietz at gcc dot gnu.org
2012-02-23 21:28 ` ktietz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).