Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 41184
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Kai Tietz <ktietz@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: drangon <drangon.mail@gmail.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
aacenc_O3.i -save-temps aacenc_O3.i text/plain 2009-08-29 08:10 31.80 KB Edit
aacenc_O3.s -save-temps aacenc_O3.s text/plain 2009-08-29 08:10 38.82 KB Edit
aacenc_O3.dump objdump of oubput aacenc.o text/plain 2009-08-29 08:11 21.64 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 41184 depends on: Show dependency tree
Show dependency graph
Bug 41184 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2009-08-29 12:33 Opened: 2009-08-29 08:09
I built an x86_64-w64-mingw32 cross compiler under x86_64 linux using 
latest gcc SVN code, then use this cross compiler to build ffmpeg.

the program runs failed, it seem that epilogue code in aac_encode_frame() 
adjust wrong rsp register.

at function aac_encode_frame() begin :

0x69fb91 <aac_encode_frame+0>:  push   %rbp
0x69fb91 <aac_encode_frame+1>:  mov    %rsp,%rbp     
0x69fb94 <aac_encode_frame+4>:  push   %r15   
0x69fb96 <aac_encode_frame+6>:  push   %r14   
0x69fb98 <aac_encode_frame+8>:  push   %r13   
0x69fb9a <aac_encode_frame+10>: push   %r12  
0x69fb9c <aac_encode_frame+12>: push   %rdi   
0x69fb9d <aac_encode_frame+13>: push   %rsi   
0x69fb9e <aac_encode_frame+14>: push   %rbx  
0x69fb9f <aac_encode_frame+15>: sub    $0x178,%rsp
0x69fba6 <aac_encode_frame+22>: mov    %rdx,0x18(%rbp)
0x69fbaa <aac_encode_frame+26>: mov    %rcx,0x10(%rbp)

it push 7 registers, when it about to quit :

0x69fd65 <aac_encode_frame+469>:        lea    -0x60(%rbp),%rsp
0x69fd69 <aac_encode_frame+473>:        movdqa 0x150(%rsp),%xmm6
0x69fd72 <aac_encode_frame+482>:        movdqa 0x160(%rsp),%xmm7
0x69fd7b <aac_encode_frame+491>:        add    $0x20,%rsp    
0x69fd7f <aac_encode_frame+495>:        pop    %rbx    
0x69fd80 <aac_encode_frame+496>:        pop    %rsi
0x69fd81 <aac_encode_frame+497>:        pop    %rdi
0x69fd82 <aac_encode_frame+498>:        pop    %r12
0x69fd84 <aac_encode_frame+500>:        pop    %r13
0x69fd86 <aac_encode_frame+502>:        pop    %r14
0x69fd88 <aac_encode_frame+504>:        pop    %r15
0x69fd8a <aac_encode_frame+506>:        leaveq
0x69fd8b <aac_encode_frame+507>:        retq

it should "add 0x28 %rsp ( not 0x20 )" after "lea    -0x60(%rbp),%rsp"


the compile command is :

/compile/mingw-w64-dgn/cross/bin/x86_64-w64-mingw32-gcc -DHAVE_AV_CONFIG_H -I.
-I"/compile/mingw-w64-dgn/lib_source/ffmpeg" -D_ISOC99_SOURCE
-D_POSIX_C_SOURCE=200112 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -std=c99
-fno-common -fomit-frame-pointer -g -Wdeclaration-after-statement -Wall
-Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls
-Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -O3
-fno-strict-aliasing -fno-math-errno -fno-signed-zeros -fno-tree-vectorize     
 -MMD -MF libavcodec/aacenc.d -MT libavcodec/aacenc.o -c -o a.o -save-temps
/compile/mingw-w64-dgn/lib_source/ffmpeg/libavcodec/aacenc.c

the -save-temps output is attached.

-O1 -O2 -O3 all has this problem, -O0 has no problem.

------- Comment #1 From drangon 2009-08-29 08:10 -------
Created an attachment (id=18447) [edit]
-save-temps aacenc_O3.i

------- Comment #2 From drangon 2009-08-29 08:10 -------
Created an attachment (id=18448) [edit]
-save-temps aacenc_O3.s

------- Comment #3 From drangon 2009-08-29 08:11 -------
Created an attachment (id=18449) [edit]
objdump of oubput aacenc.o

------- Comment #4 From xxcv07 at gmail dot com 2009-08-29 09:33 -------
Hi,

> I built an x86_64-w64-mingw32 cross compiler under x86_64 linux using 
> latest gcc SVN code, then use this cross compiler to build ffmpeg.
I can confirm this issue and encountered this problem after cross compiled VLC
with x86_64-w64-mingw32-gcc-4.4.1 from linux the resulting binary will crash
mysteriously whenever a file is played, yesterday I found out when vlc is
configured with --disable-optimizations and compile proceed with -O0 then the
resulting binary won't crash anymore.
I can't get any useful backtrace from GDB 64bits. I have looked through Process
explorer and was clueless as to why it crashed.
>
> the program runs failed, it seem that epilogue code in aac_encode_frame() 
> adjust wrong rsp register.
>
> at function aac_encode_frame() begin :
>
> 0x69fb91 <aac_encode_frame+0>:  push   %rbp
> 0x69fb91 <aac_encode_frame+1>:  mov    %rsp,%rbp     
> 0x69fb94 <aac_encode_frame+4>:  push   %r15   
> 0x69fb96 <aac_encode_frame+6>:  push   %r14   
> 0x69fb98 <aac_encode_frame+8>:  push   %r13   
> 0x69fb9a <aac_encode_frame+10>: push   %r12  
> 0x69fb9c <aac_encode_frame+12>: push   %rdi   
> 0x69fb9d <aac_encode_frame+13>: push   %rsi   
> 0x69fb9e <aac_encode_frame+14>: push   %rbx  
> 0x69fb9f <aac_encode_frame+15>: sub    $0x178,%rsp
> 0x69fba6 <aac_encode_frame+22>: mov    %rdx,0x18(%rbp)
> 0x69fbaa <aac_encode_frame+26>: mov    %rcx,0x10(%rbp)
>
> it push 7 registers, when it about to quit :
>
> 0x69fd65 <aac_encode_frame+469>:        lea    -0x60(%rbp),%rsp
> 0x69fd69 <aac_encode_frame+473>:        movdqa 0x150(%rsp),%xmm6
> 0x69fd72 <aac_encode_frame+482>:        movdqa 0x160(%rsp),%xmm7
> 0x69fd7b <aac_encode_frame+491>:        add    $0x20,%rsp    
> 0x69fd7f <aac_encode_frame+495>:        pop    %rbx    
> 0x69fd80 <aac_encode_frame+496>:        pop    %rsi
> 0x69fd81 <aac_encode_frame+497>:        pop    %rdi
> 0x69fd82 <aac_encode_frame+498>:        pop    %r12
> 0x69fd84 <aac_encode_frame+500>:        pop    %r13
> 0x69fd86 <aac_encode_frame+502>:        pop    %r14
> 0x69fd88 <aac_encode_frame+504>:        pop    %r15
> 0x69fd8a <aac_encode_frame+506>:        leaveq
> 0x69fd8b <aac_encode_frame+507>:        retq
>
> it should "add 0x28 %rsp ( not 0x20 )" after "lea    -0x60(%rbp),%rsp"
>
>
> the compile command is :
>
> /compile/mingw-w64-dgn/cross/bin/x86_64-w64-mingw32-gcc -DHAVE_AV_CONFIG_H -I.
> -I"/compile/mingw-w64-dgn/lib_source/ffmpeg" -D_ISOC99_SOURCE
> -D_POSIX_C_SOURCE=200112 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -std=c99
> -fno-common -fomit-frame-pointer -g -Wdeclaration-after-statement -Wall
> -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls
> -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -O3
> -fno-strict-aliasing -fno-math-errno -fno-signed-zeros -fno-tree-vectorize     
>  -MMD -MF libavcodec/aacenc.d -MT libavcodec/aacenc.o -c -o a.o -save-temps
> /compile/mingw-w64-dgn/lib_source/ffmpeg/libavcodec/aacenc.c
>
> the -save-temps output is attached.
>
> -O1 -O2 -O3 all has this problem, -O0 has no problem.
Now that I see you have posted this issue we can confirm that gcc is indeed
producing the wrong code with internal optimization flags, I tested dll which
will start to crash when any -O flag is present.

------- Comment #5 From Kai Tietz 2009-08-29 12:33 -------
This bug is reasoned by ix86_expand_epilogue. At one place frame.padding0
wasn't added to pro_epilogue_adjust_stack.

Following patch fixes this. It has to applied to 4.4 branch, too.

I'll post it to ML
Index: gcc/gcc/config/i386/i386.c
===================================================================
--- gcc.orig/gcc/config/i386/i386.c     2009-08-27 15:04:03.000000000 +0200
+++ gcc/gcc/config/i386/i386.c  2009-08-29 14:24:32.750680900 +0200
@@ -8949,7 +8949,7 @@
                                                frame.to_allocate, red_offset,
                                                style == 2);
          pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
-                                    GEN_INT (frame.nsseregs * 16),
+                                    GEN_INT (frame.nsseregs * 16 +
frame.padding0),
                                     style, false);
        }
       else if (frame.to_allocate || frame.nsseregs)

------- Comment #6 From xxcv07 at gmail dot com 2009-08-29 16:06 -------
Thanks Kai,
I can confirm it is now fixed, -O1 and up isn't an issue now.

------- Comment #7 From Kai Tietz 2009-08-29 18:01 -------
Committed to head at revision 151204.
Committed to 4.4 branch at revision 151203.

------- Comment #8 From Kai Tietz 2009-09-01 16:16 -------
*** Bug 39356 has been marked as a duplicate of this bug. ***

------- Comment #9 From Kai Tietz 2009-09-01 17:40 -------
*** Bug 39112 has been marked as a duplicate of this bug. ***

------- Comment #10 From Francois-Xavier Coudert 2009-09-04 12:18 -------
*** Bug 39832 has been marked as a duplicate of this bug. ***

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug