This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Memory corruption due to word sharing
- From: Colin Walters <walters at verbum dot org>
- To: Jan Kara <jack at suse dot cz>
- Cc: LKML <linux-kernel at vger dot kernel dot org>, linux-ia64 at vger dot kernel dot org, Linus Torvalds <torvalds at linux-foundation dot org>, dsterba at suse dot cz, ptesarik at suse dot cz, rguenther at suse dot de, gcc at gcc dot gnu dot org
- Date: Wed, 01 Feb 2012 11:37:45 -0500
- Subject: Re: Memory corruption due to word sharing
- References: <20120201151918.GC16714@quack.suse.cz>
On Wed, 2012-02-01 at 16:19 +0100, Jan Kara wrote:
> I've raised the issue with our GCC guys and they said to me that: "C does
> not provide such guarantee, nor can you reliably lock different
> structure fields with different locks if they share naturally aligned
> word-size memory regions. The C++11 memory model would guarantee this,
> but that's not implemented nor do you build the kernel with a C++11
> compiler."
That's interesting. So it seems like there are two solutions:
1) Use the same lock for a given bitfield
2) Split up the bitfield into different words