As reported in pr55679 comment #12, the tests c-c++-common/asan/(global|stack)-overflow-1.c fail on x86_64-apple-darwin* with optimization because the out of bound read is optimized out. Is the optimization sound? If yes, why does not it occur for linux? If no, why does it occur for darwin? The tests pass with /* { dg-options "-fno-builtin-memset -fno-tree-fre -fno-tree-pre" } */
I have forgotten to CC Jack Howarth.
The optimization is sound without -fno-builtin-memset. Otherwise not - why would that not be in effect for darwin? Can you attach preprocessed source please?
Just guessing, perhaps Darwin headers define memset using __builtin_memset? So, perhaps we should ditch #include <string.h> and define the prototypes ourselves, then it isn't dependent on the target headers.
Created attachment 29293 [details] preprocessed source for global-overflow-1.c > Can you attach preprocessed source please? Done for global-overflow-1.c.
Seems to fortify by default and thus expose a builtin anyway.
Created attachment 29295 [details] gcc48-pr56053.patch Untested fix.
> Created attachment 29295 [details] > gcc48-pr56053.patch > > Untested fix. On x86_64-apple-darwin10, with the patch make -k check-gcc RUNTESTFLAGS="asan.exp --target_board=unix'{-m32,-m64}'" gives === gcc Summary === # of expected passes 516 # of unsupported tests 76 and check-g++ gives === g++ Summary === # of expected passes 810 # of unsupported tests 138 So the patch fixes this PR at least on darwin.
Author: jakub Date: Mon Jan 28 14:28:16 2013 New Revision: 195505 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195505 Log: PR testsuite/56053 * c-c++-common/asan/heap-overflow-1.c: Don't include stdlib.h and string.h. Provide memset, malloc and free prototypes, adjust line numbers in dg-output. * c-c++-common/asan/stack-overflow-1.c: Don't include string.h. Provide memset prototype and adjust line numbers in dg-output. * c-c++-common/asan/global-overflow-1.c: Likewise. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/c-c++-common/asan/global-overflow-1.c trunk/gcc/testsuite/c-c++-common/asan/heap-overflow-1.c trunk/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c
Should be fixed now.