Re: gcc generated long read out of bounds segfault

2014-02-22 Thread Andreas Schwab
David Fries writes: > The structure is only made up of an 8 bit type "char", and it is > aligned to a multiple of the struct rgb data size which is 3. How is > that unaligned? Sorry, I've miscomputed the alignment. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA

Re: gcc generated long read out of bounds segfault

2014-02-22 Thread David Fries
On Sat, Feb 22, 2014 at 08:49:38AM +0100, Andreas Schwab wrote: > David Fries writes: > > > The attached program sets up and reads through the array with extra > > padding at the of the array from 8 bytes to 0 bytes. Padding from 4 > > to 0 crashes. > > This program has undefined behaviour beca

Re: gcc generated long read out of bounds segfault

2014-02-22 Thread Eric Botcazou
> Before I file a bug report I wanted to check to see if my expectations > are wrong or if this is a compiler bug. Is there anything that allows > the compiler to generate instructions that would read beyond the end > of an array potentially causing a crash if the page isn't accessible? It's PR m

Re: gcc generated long read out of bounds segfault

2014-02-21 Thread Andreas Schwab
David Fries writes: > The attached program sets up and reads through the array with extra > padding at the of the array from 8 bytes to 0 bytes. Padding from 4 > to 0 crashes. This program has undefined behaviour because you are using unaligned pointers. Andreas. -- Andreas Schwab, sch...@li

gcc generated long read out of bounds segfault

2014-02-21 Thread David Fries
I was using valgrind and found an out of bounds error reading 8 bytes off an array of 3 byte data structures where the extra 5 bytes being read were out of the array bounds. I attached a program that ends the array at the end of a page so reading beyond the end of the array would cause a crash, an