public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/52445] New: conditional store replacement causes segfault in generated code
@ 2012-03-01  4:47 gcc at adamsimpkins dot net
  2012-03-01  4:55 ` [Bug tree-optimization/52445] " pinskia at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: gcc at adamsimpkins dot net @ 2012-03-01  4:47 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52445
           Summary: conditional store replacement causes segfault in
                    generated code
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gcc@adamsimpkins.net


Created attachment 26797
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26797
minimized test case

The cond_store_replacement() optimization can move a memory access outside of a
conditional statement that checks whether it is safe to access the memory. 
This can cause the program to segfault.

I've attached a simplified test case that reproduces the problem.  It uses
mprotect to ensure the following byte is inaccessible.  In practice we see
segfaults simply because malloc sometimes returns a buffer at the end of a
readable region.  The conditional store replacement moves the memory access
outside of the length check.

I've verified the problem occurs in 4.6.1, 4.6.2, and the gcc-4.6.2-20120210
and gcc-4.7-20120225 snapshots.  The problem doesn't occur with 4.4.5, as it
doesn't perform conditional store replacement in this case.


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

end of thread, other threads:[~2013-04-03 18:16 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-01  4:47 [Bug tree-optimization/52445] New: conditional store replacement causes segfault in generated code gcc at adamsimpkins dot net
2012-03-01  4:55 ` [Bug tree-optimization/52445] " pinskia at gcc dot gnu.org
2012-03-01  4:56 ` [Bug tree-optimization/52445] [4.6/4.6 Regression] " pinskia at gcc dot gnu.org
2012-03-01  7:59 ` [Bug tree-optimization/52445] [4.6/4.7 " jakub at gcc dot gnu.org
2012-03-01  8:55 ` jakub at gcc dot gnu.org
2012-03-01  9:02 ` jakub at gcc dot gnu.org
2012-03-01  9:15 ` jakub at gcc dot gnu.org
2012-03-01 10:37 ` jakub at gcc dot gnu.org
2012-03-01 10:48 ` rguenth at gcc dot gnu.org
2012-03-01 10:51 ` jakub at gcc dot gnu.org
2012-03-01 12:13 ` rguenth at gcc dot gnu.org
2012-03-01 12:32 ` jakub at gcc dot gnu.org
2012-03-01 14:13 ` jakub at gcc dot gnu.org
2012-03-01 15:13 ` jakub at gcc dot gnu.org
2012-03-01 15:39 ` [Bug tree-optimization/52445] [4.6 " jakub at gcc dot gnu.org
2012-03-01 15:48 ` jakub at gcc dot gnu.org
2012-09-11 14:21 ` mikpe at it dot uu.se
2013-04-03 18:16 ` jakub 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).