public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/34716]  New: application segfaults when compiled with -O2, but works well with -O1
@ 2008-01-08 19:29 aleksey dot shipilev at gmail dot com
  2008-01-08 19:36 ` [Bug rtl-optimization/34716] " aleksey dot shipilev at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: aleksey dot shipilev at gmail dot com @ 2008-01-08 19:29 UTC (permalink / raw)
  To: gcc-bugs

When building application (namely, powertweak) with gcc 4.1.2 using -02,
application experiences segfault during startup. When building in the same
configuration but using -O1, all works fine.

Attached microtest (test.c) which resembles the problem:

# gcc test.c && ./a.out
before: output=bff74f74, buf=bff74d74
after:  output=bff74f74, buf=bff74d74
sizeof(buf)=512
result=0

# gcc -O1 test.c && ./a.out
before: output=bff0b700, buf=bff0b500
after:  output=bff0b700, buf=bff0b500
sizeof(buf)=512
result=0

# gcc -O2 test.c && ./a.out
before: output=bfd004fc, buf=bfd002fc
after:  output=bfd004fc, buf=bfd002fc
sizeof(buf)=512
result=0
Segmentation fault    <-------

If I try to hunt down the differences between -O1 and -O2 as described at 
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Optimize-Options.html:

# gcc -O1 -fthread-jumps -fcrossjumping -foptimize-sibling-calls
-fcse-follow-jumps  -fcse-skip-blocks -fgcse  -fgcse-lm 
-fexpensive-optimizations -fstrength-reduce -frerun-cse-after-loop 
-frerun-loop-opt -fcaller-saves -fpeephole2 -fschedule-insns  -fschedule-insns2
-fsched-interblock  -fsched-spec -fregmove -fstrict-aliasing
-fdelete-null-pointer-checks -freorder-blocks  -freorder-functions
-falign-functions  -falign-jumps -falign-loops  -falign-labels -ftree-vrp
-ftree-pre test.c && ./a.out
before: output=bfd4ed60, buf=bfd4eb60
after:  output=bfd4ed60, buf=bfd4eb60
sizeof(buf)=512
result=0

All is OK, so I have failed to find guilty optimization.

Moreover, when I try to disable all optimizations described at
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Option-Summary.html under
"Optimization options":

# gcc -O2 -fno-align-functions -fno-align-jumps -fno-align-labels
-fno-align-loops -fno-sched-stalled-insns -fno-bounds-check
-fno-branch-probabilities -fno-profile-values -fno-vpt
-fno-branch-target-load-optimize -fno-branch-target-load-optimize2
-fno-btr-bb-exclusive -fno-caller-saves  -fno-cprop-registers 
-fno-cse-follow-jumps -fno-cse-skip-blocks  -fno-cx-limited-range 
-fno-data-sections -fno-delete-null-pointer-checks -fno-early-inlining
-fno-expensive-optimizations  -fno-fast-math  -fno-float-store -fno-force-addr 
-fno-function-sections -fno-gcse  -fno-gcse-lm  -fno-gcse-sm  -fno-gcse-las 
-fno-gcse-after-reload -fno-loop-optimize -fno-crossjumping  -fno-if-conversion
 -fno-if-conversion2 -fno-inline-functions -fno-inline-functions-called-once
-fno-keep-inline-functions -fno-keep-static-consts  -fno-merge-constants
-fno-merge-all-constants -fno-modulo-sched -fno-branch-count-reg -fno-defer-pop
-fno-loop-optimize2 -fno-move-loop-invariants -fno-function-cse 
-fno-guess-branch-probability -fno-inline  -fno-math-errno  -fno-peephole 
-fno-peephole2 -fno-unsafe-math-optimizations  -fno-unsafe-loop-optimizations 
-fno-finite-math-only -fno-trapping-math  -fno-zero-initialized-in-bss
-fno-omit-frame-pointer  -fno-optimize-register-move
-fno-optimize-sibling-calls -fno-prefetch-loop-arrays -fno-profile-generate
-fno-profile-use -fno-regmove  -fno-rename-registers -fno-reorder-blocks 
-fno-reorder-blocks-and-partition -fno-reorder-functions
-fno-rerun-cse-after-loop  -fno-rerun-loop-opt -fno-rounding-math
-fno-schedule-insns  -fno-schedule-insns2 -fno-sched-interblock 
-fno-sched-spec  -fno-sched-spec-load -fno-sched-spec-load-dangerous 
-fno-sched2-use-superblocks -fno-sched2-use-traces
-fno-reschedule-modulo-scheduled-loops -fno-signaling-nans
-fno-single-precision-constant  -fno-stack-protector  -fno-strength-reduce 
-fno-strict-aliasing  -fno-tracer  -fno-thread-jumps -fno-unroll-all-loops 
-fno-unroll-loops  -fno-peel-loops -fno-split-ivs-in-unroller
-fno-unswitch-loops -fno-variable-expansion-in-unroller -fno-tree-pre 
-fno-tree-ccp  -fno-tree-dce -fno-tree-loop-optimize -fno-tree-loop-linear
-fno-tree-loop-im -fno-tree-loop-ivcanon -fno-ivopts -fno-tree-dominator-opts
-fno-tree-dse -fno-tree-copyrename -fno-tree-sink -fno-tree-ch -fno-tree-sra
-fno-tree-ter -fno-tree-lrs -fno-tree-fre -fno-tree-vectorize
-fno-tree-vect-loop-version -fno-tree-salias -fno-web -fno-tree-copy-prop
-fno-tree-store-ccp -fno-tree-store-copy-prop -fno-whole-program  test.c &&
./a.out
before: output=bfca84ac, buf=bfca82ac
after:  output=bfca84ac, buf=bfca82ac
sizeof(buf)=512
result=0
Segmentation fault <-------

Still, I have segmentation fault, but all optimization seem to be disabled.

There is easy workaround though (not to compile with -O2), but I believe this
issue worth fixing.


-- 
           Summary: application segfaults when compiled with -O2, but works
                    well with -O1
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aleksey dot shipilev at gmail dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2014-08-04 10:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-34716-4@http.gcc.gnu.org/bugzilla/>
2014-08-04 10:43 ` [Bug rtl-optimization/34716] application segfaults when compiled with -O2, but works well with -O1 ktietz at gcc dot gnu.org
2014-08-04 10:44 ` ktietz at gcc dot gnu.org
2008-01-08 19:29 [Bug rtl-optimization/34716] New: " aleksey dot shipilev at gmail dot com
2008-01-08 19:36 ` [Bug rtl-optimization/34716] " aleksey dot shipilev at gmail dot com
2008-01-08 19:58 ` pinskia at gcc dot gnu dot org
2008-01-08 20:07 ` aleksey dot shipilev at gmail dot com
2008-01-08 21:21 ` aleksey dot shipilev at gmail dot com
2008-01-08 21:22 ` pinskia at gcc dot gnu dot org
2008-01-08 21:23 ` aleksey dot shipilev at gmail dot com

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).