Bug 33424 - segmentation fault for legal code with -O2
Summary: segmentation fault for legal code with -O2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 36635
Blocks: 37290
  Show dependency treegraph
 
Reported: 2007-09-13 20:08 UTC by David Binderman
Modified: 2008-12-26 09:55 UTC (History)
1 user (show)

See Also:
Host:
Target: suse-linux-x86_64
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-08-31 12:27:34


Attachments
C source code (44.80 KB, text/plain)
2007-09-13 20:09 UTC, David Binderman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2007-09-13 20:08:23 UTC
I just tried to compile Suse Linux package mysql-5.0.45-18
with the GNU C compiler version 4.3 snapshot 20070907.

The compiler said

if gcc -DHAVE_CONFIG_H -I. -I../../strings -I.. -I../include -I../../include    -DDBUG_OFF -O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2 -DPIC -fPIC -DUNDEF_HAVE_INITGROUPS -DFORCE_INIT_OF_VARS -fno-strict-aliasing   -MT ctype-utf8.o -MD -MP -MF ".deps/ctype-utf8.Tpo" -c -o ctype-utf8.o ../../strings/ctype-utf8.c; \
        then mv -f ".deps/ctype-utf8.Tpo" ".deps/ctype-utf8.Po"; else rm -f ".deps/ctype-utf8.Tpo"; exit 1; fi
In file included from ../../strings/ctype-utf8.c:21:
../../include/my_global.h:556: warning: function declaration isn't a prototype
../../strings/ctype-utf8.c: In function 'my_strnncollsp_utf8':
../../strings/ctype-utf8.c:2448: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Here is some help from valgrind

==19535== Invalid read of size 2
==19535==    at 0x9FFF59: cse_cc_succs (cse.c:6737)
==19535==    by 0xA08F11: rest_of_handle_cse2 (cse.c:6962)
==19535==    by 0x631218: execute_one_pass (passes.c:1115)
==19535==    by 0x6313EF: execute_pass_list (passes.c:1168)
==19535==    by 0x631404: execute_pass_list (passes.c:1169)
==19535==    by 0x70957F: tree_rest_of_compilation (tree-optimize.c:404)
==19535==    by 0x8767DF: cgraph_expand_function (cgraphunit.c:1077)
==19535==    by 0x878A3D: cgraph_optimize (cgraphunit.c:1146)
==19535==    by 0x41625D: c_write_global_declarations (c-decl.c:8080)
==19535==    by 0x6B095F: toplev_main (toplev.c:1058)
==19535==    by 0x52BDB43: (below main) (in /lib64/libc-2.6.so)
==19535==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
/tmp/q.i: In function 'my_strnncollsp_utf8':
/tmp/q.i:10725: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Preprocessed source attached. Flag -O2 required.
Comment 1 David Binderman 2007-09-13 20:09:38 UTC
Created attachment 14207 [details]
C source code
Comment 2 Richard Biener 2008-08-31 12:27:34 UTC
We endlessly recurse in cse_cc_succs on i686-pc-linux-gnu with -O3.  Related to
PR36635.
Comment 3 Andrew Pinski 2008-12-25 17:50:48 UTC
I think this is fixed on the trunk now.
Comment 4 David Binderman 2008-12-26 09:55:33 UTC
(In reply to comment #3)
> I think this is fixed on the trunk now.

I agree. I just re-checked it and it seems 
fixed to me.