Bug 30247 - [4.2/4.3] Gcc miscompiles MPlayer when any optimization is used
Summary: [4.2/4.3] Gcc miscompiles MPlayer when any optimization is used
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-18 10:09 UTC by İsmail Dönmez
Modified: 2006-12-19 09:31 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
mp_msg.c compiled with -O0 (10.32 KB, application/octet-stream)
2006-12-18 10:10 UTC, İsmail Dönmez
Details
mp_msg.c compiled with -O1 (11.92 KB, application/octet-stream)
2006-12-18 10:11 UTC, İsmail Dönmez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description İsmail Dönmez 2006-12-18 10:09:40 UTC
gcc 4.2 branch and gcc 4.3 SVN snapshot seems to miscompile MPlayer's mp_msg.c resulting in a crash. gcc 3.4.6 is ok. During compilation no warning is issued.

Gcc tested is :
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/cartman/gcc_4.2 --enable-clocale=gnu --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++ --disable-nls
Thread model: posix
gcc version 4.2.0 20061217 (prerelease)


I will attach two files:

mp_msg_compiled_with_O1_crashes.i produced with :

cc -O1 -Wdeclaration-after-statement -march=pentium-m -mtune=pentium-m -pipe -ffast-math -fomit-frame-pointer -D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I/usr/include -I/usr/include/  -I/usr/include/SDL  -D_REENTRANT -I/usr/include -I/usr/include/dvdnav  -I/usr/include/freetype2 -I. -I./libavutil -I./libavcodec  -c -save-temps mp_msg.c

mp_msg_compiled_with_O0_works.i produced with:

cc -O0 -Wdeclaration-after-statement -march=pentium-m -mtune=pentium-m -pipe -ffast-math -fomit-frame-pointer -D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I/usr/include -I/usr/include/  -I/usr/include/SDL  -D_REENTRANT -I/usr/include -I/usr/include/dvdnav  -I/usr/include/freetype2 -I. -I./libavutil -I./libavcodec  -c -save-temps mp_msg.c
Comment 1 İsmail Dönmez 2006-12-18 10:10:31 UTC
Created attachment 12823 [details]
mp_msg.c compiled with -O0
Comment 2 İsmail Dönmez 2006-12-18 10:11:11 UTC
Created attachment 12824 [details]
mp_msg.c compiled with -O1
Comment 3 İsmail Dönmez 2006-12-18 10:15:57 UTC
Valgrinding the crashing mplayer shows:

==5836== Invalid read of size 1
==5836==    at 0x401E776: strlen 
(in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==5836==    by 0x4B4049E: fprintf (in /lib/libc-2.3.6.so)
==5836==    by 0x81098CF: open (vf_ass.c:395)
==5836==    by 0x80DC4F6: vf_open_plugin (vf.c:466)
==5836==    by 0x80831F6: reinit_video_chain (mplayer.c:3321)
==5836==    by 0x8086699: main (mplayer.c:4517)
==5836==  Address 0x5248003E is not stack'd, malloc'd or (recently) free'd                                                                                   
which shows line 182 in mp_msg.c which is something like:

  fprintf(stream, "\033[%d;3%dm%9s\033[0;37m: ",c2>>3,c2&7, 
mod_text[mod]);

If I replace mod_text[mod] with "foo" it doesn't crash anymore.
Comment 4 Andrew Pinski 2006-12-18 10:26:11 UTC
There is no obvious what is wrong from the tree dumps.
Comment 5 İsmail Dönmez 2006-12-18 10:39:07 UTC
I tried to follow http://gcc.gnu.org/bugs.html#need . Anything else I should provide?
Comment 6 İsmail Dönmez 2006-12-19 09:31:50 UTC
Another MPlayer bug exposed by gcc, sorry guys!