diff options
author | Martin Liska <mliska@suse.cz> | 2016-11-30 10:26:51 +0100 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2016-11-30 09:26:51 +0000 |
commit | fb61d96cf20d5bb6db8fd72ef7b528804e9f6be4 (patch) | |
tree | dbeaebeaf71880f943227264b45ccfab26cf47de | |
parent | e03fb6ec681070048ecc0f1f2d2a299dc3d3db1a (diff) | |
download | gcc-fb61d96cf20d5bb6db8fd72ef7b528804e9f6be4.zip gcc-fb61d96cf20d5bb6db8fd72ef7b528804e9f6be4.tar.gz gcc-fb61d96cf20d5bb6db8fd72ef7b528804e9f6be4.tar.bz2 |
Support nested functions (PR sanitizer/78541).
PR sanitizer/78541
* gcc.dg/asan/pr78541-2.c: New test.
* gcc.dg/asan/pr78541.c: New test.
PR sanitizer/78541
* asan.c (asan_expand_mark_ifn): Properly
select a VAR_DECL from FRAME.* component reference.
From-SVN: r243003
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/asan.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/asan/pr78541-2.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/asan/pr78541.c | 25 |
5 files changed, 53 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f8e450..c68d3c9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-11-30 Martin Liska <mliska@suse.cz> + + PR sanitizer/78541 + * asan.c (asan_expand_mark_ifn): Properly + select a VAR_DECL from FRAME.* component reference. + 2016-11-30 Segher Boessenkool <segher@kernel.crashing.org> PR rtl-optimization/78583 @@ -2713,6 +2713,12 @@ asan_expand_mark_ifn (gimple_stmt_iterator *iter) tree base = gimple_call_arg (g, 1); gcc_checking_assert (TREE_CODE (base) == ADDR_EXPR); tree decl = TREE_OPERAND (base, 0); + + /* For a nested function, we can have: ASAN_MARK (2, &FRAME.2.fp_input, 4) */ + if (TREE_CODE (decl) == COMPONENT_REF + && DECL_NONLOCAL_FRAME (TREE_OPERAND (decl, 0))) + decl = TREE_OPERAND (decl, 0); + gcc_checking_assert (TREE_CODE (decl) == VAR_DECL); if (asan_handled_variables == NULL) asan_handled_variables = new hash_set<tree> (16); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a79a4a8..3074e6d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-11-30 Martin Liska <mliska@suse.cz> + + PR sanitizer/78541 + * gcc.dg/asan/pr78541-2.c: New test. + * gcc.dg/asan/pr78541.c: New test. + 2016-11-30 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/78586 diff --git a/gcc/testsuite/gcc.dg/asan/pr78541-2.c b/gcc/testsuite/gcc.dg/asan/pr78541-2.c new file mode 100644 index 0000000..44be19c --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr78541-2.c @@ -0,0 +1,10 @@ +/* PR sanitizer/78560 */ +/* { dg-do compile } */ + +void __quadmath_mpn_extract_flt128 (long *fp_input); + +int fn1 () +{ + long fp_input[1]; + int hack_digit () { __quadmath_mpn_extract_flt128 (fp_input); } +} diff --git a/gcc/testsuite/gcc.dg/asan/pr78541.c b/gcc/testsuite/gcc.dg/asan/pr78541.c new file mode 100644 index 0000000..fb02082 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr78541.c @@ -0,0 +1,25 @@ +// PR sanitizer/78560 +// { dg-do run } +// { dg-shouldfail "asan" } + +void foo (double a, double b) +{ + double *ptr; + { + double x = a + b; + ptr = &x; + } + double square () { __builtin_printf ("", *ptr); } + + square (); +} + +int main() +{ + foo (1.2f, 2.3f); + return 0; +} + +// { dg-output "ERROR: AddressSanitizer: stack-use-after-scope on address.*(\n|\r\n|\r)" } +// { dg-output "READ of size.*" } +// { dg-output ".*'x' <== Memory access at offset \[0-9\]* is inside this variable.*" } |