Bug 56053 - FAIL: c-c++-common/asan/(global|stack)-overflow-1.c
Summary: FAIL: c-c++-common/asan/(global|stack)-overflow-1.c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-20 16:47 UTC by Dominique d'Humieres
Modified: 2013-01-28 14:31 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-01-20 00:00:00


Attachments
preprocessed source for global-overflow-1.c (1.62 KB, text/plain)
2013-01-28 12:16 UTC, Dominique d'Humieres
Details
gcc48-pr56053.patch (954 bytes, patch)
2013-01-28 13:00 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dominique d'Humieres 2013-01-20 16:47:26 UTC
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" } */
Comment 1 Dominique d'Humieres 2013-01-20 16:52:14 UTC
I have forgotten to CC Jack Howarth.
Comment 2 Richard Biener 2013-01-28 12:07:12 UTC
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?
Comment 3 Jakub Jelinek 2013-01-28 12:10:57 UTC
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.
Comment 4 Dominique d'Humieres 2013-01-28 12:16:32 UTC
Created attachment 29293 [details]
preprocessed source for global-overflow-1.c

> Can you attach preprocessed source please?

Done for global-overflow-1.c.
Comment 5 Richard Biener 2013-01-28 12:34:15 UTC
Seems to fortify by default and thus expose a builtin anyway.
Comment 6 Jakub Jelinek 2013-01-28 13:00:00 UTC
Created attachment 29295 [details]
gcc48-pr56053.patch

Untested fix.
Comment 7 Dominique d'Humieres 2013-01-28 14:06:35 UTC
> 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.
Comment 8 Jakub Jelinek 2013-01-28 14:28:24 UTC
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
Comment 9 Jakub Jelinek 2013-01-28 14:31:35 UTC
Should be fixed now.