This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] tell gcc optimizer to never introduce new data races
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Steven Noonan <steven at uplinklabs dot net>,Linus Torvalds <torvalds at linux-foundation dot org>
- Cc: Jiri Kosina <jkosina at suse dot cz>,"Paul E. McKenney" <paulmck at linux dot vnet dot ibm dot com>,Peter Zijlstra <peterz at infradead dot org>,Andrew Morton <akpm at linux-foundation dot org>,Martin Jambor <mjambor at suse dot cz>,Petr Mladek <pmladek at suse dot cz>,Linux Kernel Mailing List <linux-kernel at vger dot kernel dot org>,"gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Tue, 10 Jun 2014 20:54:09 +0200
- Subject: Re: [PATCH] tell gcc optimizer to never introduce new data races
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LNX dot 2 dot 00 dot 1406101517300 dot 9378 at pobox dot suse dot cz> <CA+55aFyY7_=3xt-0KE=-fmb+kLurxkBmh8TZWgDZMi_RVpKBpg at mail dot gmail dot com> <CAKbGBLi1hRxe03EB70HOYRTuVhHkAyTnhfv8HFXEwatP6Qn8tA at mail dot gmail dot com>
On June 10, 2014 8:04:13 PM CEST, Steven Noonan <email@example.com> wrote:
>On Tue, Jun 10, 2014 at 10:46 AM, Linus Torvalds
>> On Tue, Jun 10, 2014 at 6:23 AM, Jiri Kosina <firstname.lastname@example.org> wrote:
>>> We have been chasing a memory corruption bug, which turned out to be
>>> caused by very old gcc (4.3.4), which happily turned conditional
>>> a non-conditional one, and that broke correctness (the condition was
>>> only if lock was held) and corrupted memory.
>> Just out of interest, can you point to the particular kernel code
>> caused this? I think that's more interesting than the example program
>> you show - which I'm sure is really nice for gcc developers as an
>> example, but from a kernel standpoint I think it's more important to
>> show the particular problems this caused for the kernel?
>Jiri, is there a workaround for compilers that don't support '--param
>allow-store-data-races=0'? For example:
The optimization that purposely performs the undesired transform is loop store motion which is part of the tree loop invariant motion optimization. You can disable that with -fno-tree-loop-im.
That the bug didn't appear with newer compilers was due to lucky decisions to not inline a particular function.
>$ gcc-4.5 -O2 -o cond_store cond_store.c && ./cond_store
>Segmentation fault (core dumped)
>$ gcc-4.5 -O2 --param allow-store-data-races=0 -o cond_store
>cond_store.c && ./cond_store
>cc1: error: invalid parameter âallow-store-data-racesâ
>$ gcc-4.5 -v
>Using built-in specs.
>Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
>--infodir=/usr/share/info --libdir=/usr/lib --libexecdir=/usr/lib
>--disable-libstdcxx-pch --disable-multilib --disable-libgomp
>--disable-libmudflap --disable-libssp --enable-clocale=gnu
>--with-tune=generic --with-cloog --with-ppl --with-system-zlib
>Thread model: posix
>gcc version 4.5.4 (GCC)