From: Marek Polacek Date: Tue, 10 Mar 2015 15:57:45 +0000 (+0000) Subject: re PR sanitizer/65367 (indefinite loop occurs with sanitize enabled and certain optim... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0757674c837edede75a9c8a840c55190f971c004;p=gcc.git re PR sanitizer/65367 (indefinite loop occurs with sanitize enabled and certain optimization options) PR sanitizer/65367 * ubsan.c (ubsan_expand_objsize_ifn): Update GSI instead of GSI_ORIG when only removing the statement. Handle expanding UBSAN_OBJECT_SIZE separately. * c-c++-common/ubsan/pr65367.c: New test. Co-Authored-By: Jakub Jelinek From-SVN: r221325 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 21f9b950789..95d0fcf9ae9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-03-10 Marek Polacek + Jakub Jelinek + + PR sanitizer/65367 + * ubsan.c (ubsan_expand_objsize_ifn): Update GSI instead of GSI_ORIG + when only removing the statement. Handle expanding UBSAN_OBJECT_SIZE + separately. + 2015-03-10 Jakub Jelinek PR target/65286 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 564944dab57..869dee04e65 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-03-10 Marek Polacek + + PR sanitizer/65367 + * c-c++-common/ubsan/pr65367.c: New test. + 2015-03-10 Ilya Enkovich * lib/mpx-dg.exp (mpx_link_flags): Set path to wrappers library. diff --git a/gcc/testsuite/c-c++-common/ubsan/pr65367.c b/gcc/testsuite/c-c++-common/ubsan/pr65367.c new file mode 100644 index 00000000000..a98d797e9f6 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/pr65367.c @@ -0,0 +1,9 @@ +/* PR sanitizer/65367 */ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-ccp -fno-tree-copy-prop -fno-tree-dominator-opts -fno-tree-fre -fsanitize=object-size" } */ + +int +foo (char *p) +{ + return *((const char *) "") - *p; +} diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 38d98cfd4e0..98edfe03a25 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1022,11 +1022,16 @@ ubsan_expand_objsize_ifn (gimple_stmt_iterator *gsi) /* Point GSI to next logical statement. */ *gsi = gsi_start_bb (fallthru_bb); + + /* Get rid of the UBSAN_OBJECT_SIZE call from the IR. */ + unlink_stmt_vdef (stmt); + gsi_remove (&gsi_orig, true); + return true; } /* Get rid of the UBSAN_OBJECT_SIZE call from the IR. */ unlink_stmt_vdef (stmt); - gsi_remove (&gsi_orig, true); + gsi_remove (gsi, true); return true; }