This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Obscure crashes due to gcc 4.9 -O2 => -fisolate-erroneous-paths-dereference
- From: Jeff Law <law at redhat dot com>
- To: Martin Sebor <msebor at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>, Florian Weimer <fweimer at redhat dot com>
- Cc: Sandra Loosemore <sandra at codesourcery dot com>, Jeff Prothero <jprother at altera dot com>, gcc at gcc dot gnu dot org
- Date: Tue, 03 Mar 2015 16:38:03 -0700
- Subject: Re: Obscure crashes due to gcc 4.9 -O2 => -fisolate-erroneous-paths-dereference
- Authentication-results: sourceware.org; auth=none
- References: <pdf61azt48b dot fsf at sj-interactive3 dot altera dot com> <20150218192943 dot GR1746 at tucnak dot redhat dot com> <54E64DFF dot 8030100 at codesourcery dot com> <54E71534 dot 8070805 at redhat dot com> <20150220121014 dot GY1746 at tucnak dot redhat dot com> <54E76865 dot 4010305 at redhat dot com> <54F61214 dot 7030407 at redhat dot com>
On 03/03/15 12:57, Martin Sebor wrote:
As a data point(*) it might be interesting to note that GCC itself
relies on memcpy providing stronger guarantees than the C standard
requires it to by emitting calls to the function for large structure
self-assignments (which are strictly conforming, as discussed in bug
65029).
Right. I actually spent quite a bit of time struggling with this a
while back in a different context. The only case I could come up with
where GCC would generate an overlapping memcpy was self assignment, but
even that was bad and while we ultimately punted, I've always considered
it a wart.
[*] IMO, one in favor of tightening up the memcpy specification
to require implementations to provide the expected semantics.
That works for me :-)
The things done in glibc's memcpy are a bit on the absurd side and the
pain caused by the changes over time is almost impossible to overstate.
If the Austin group tightens memcpy to require fewer surprises I think
most developers would ultimately be happy with the result -- a few would
complain about the performance impacts for specific workloads, but I
suspect they'd be in the minority.
jeff