[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <A3E67C2071F49C4CBC4F17E6D77CDDD232754183@G4W3299.americas.hpqcorp.net>
Date: Wed, 1 Feb 2012 21:25:39 +0000
From: "Boehm, Hans" <hans.boehm@...com>
To: Linus Torvalds <torvalds@...ux-foundation.org>,
Torvald Riegel <triegel@...hat.com>
CC: Jan Kara <jack@...e.cz>, LKML <linux-kernel@...r.kernel.org>,
"linux-ia64@...r.kernel.org" <linux-ia64@...r.kernel.org>,
"dsterba@...e.cz" <dsterba@...e.cz>,
"ptesarik@...e.cz" <ptesarik@...e.cz>,
"rguenther@...e.de" <rguenther@...e.de>,
"gcc@....gnu.org" <gcc@....gnu.org>
Subject: RE: Memory corruption due to word sharing
> From: Linus Torvalds
> Don't try to make it anything more complicated. This has *nothing* to
> do with threads or functions or anything else.
>
> If you do massive inlining, and you don't see any barriers or
> conditionals or other reasons not to write to it, just write to it.
>
> Don't try to appear smart and make this into something it isn't.
>
> Look at the damn five-line example of the bug. FIX THE BUG. Don't try
> to make it anything bigger than a stupid compiler bug. Don't try to
> make this into a problem it simply isn't.
>
My impression is that all of us not on the hook to fix this are in violent agreement on this example.
Here are some more interesting ones that illustrate the issues (all declarations are non-local, unless stated otherwise):
struct { char a; int b:9; int c:7; char d} x;
Is x.b = 1 allowed to overwrite x.a? C11 says no, essentially requiring two byte stores. Gcc currently does so. I'm not sure I understand Linus' position here.
int count;
/* p and q are local */
for (q = p; q = q -> next; q != 0) if (q -> data > 0) ++count;
Can count be promoted to a register, and thus written even if there are no positive elements. C11 says no. gcc at least used to do this.
for (q = p; q = q -> next; q != 0) { ++count; if (rare_cond) f(); }
Same question, with cond saved and restored around the call to f() (which might include a fence). C11 says no. I think Linus is also arguing for no.
for (i = 0; i < 1000; ++i) { if (i%1) a[i] = i; }
Can I vectorize the loop writing back the original even values, and thus writing all entries of the array. C11 and Linus both say no.
My impression is that we are generally in agreement.
Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists