[committed] analyzer: fix usage of "_setjmp" in test for PR 93378
diff mbox series

Message ID 20200122203640.30702-1-dmalcolm@redhat.com
State New
Headers show
Series
  • [committed] analyzer: fix usage of "_setjmp" in test for PR 93378
Related show

Commit Message

David Malcolm Jan. 22, 2020, 8:36 p.m. UTC
On Wed, 2020-01-22 at 14:56 -0500, David Malcolm wrote:
> PR analyzer/93378 reports an ICE at -O1 -g when analyzing a rewind
> via
> longjmp to a setjmp call with.
> 
> The root cause is that the rewind_info_t::get_setjmp_call attempts to
> locate the setjmp GIMPLE_CALL via within the exploded_node containing
> it, but the exploded_node has two stmts: a GIMPLE_DEBUG, then the
> GIMPLE_CALL, and so erroneously picks the GIMPLE_DEBUG, leading to
> a failed as_a <const gcall *>.
> 
> This patch reworks how the analyzer stores information about a setjmp
> so that instead of storing an exploded_node *, it instead introduces
> a "setjmp_record" struct, for use by both setjmp_svalue and
> rewind_info_t.  Hence we store the information directly, rather than
> attempting to reconstruct it, fixing the bug.
> 
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu;
> pushed to master as r10-6153-
> gfd9982bb0051d1a678191b684bb907d1ac177991.

[...]

> diff --git a/gcc/testsuite/gcc.dg/analyzer/setjmp-pr93378.c
> b/gcc/testsuite/gcc.dg/analyzer/setjmp-pr93378.c
> new file mode 100644
> index 00000000000..7934a40301d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/analyzer/setjmp-pr93378.c
> @@ -0,0 +1,15 @@
> +/* { dg-additional-options "-O1 -g" } */
> +
> +#include <setjmp.h>
> +
> +jmp_buf buf;
> +
> +int
> +test (void)
> +{
> +  if (_setjmp (buf) != 0)
> +    return 0;
> +
> +  longjmp (buf, 1);
> +  return 1;
> +}

I realized belatedly that the above introduces an assumption that
<setjmp.h> declares a _setjmp, so I've pushed the following folloup,
having tested on x86_64-pc-linux-gnu and x86_64-pc-linux-gnu.

gcc/testsuite/ChangeLog:
	PR analyzer/93378
	* gcc.dg/analyzer/setjmp-pr93378.c: Use setjmp rather than
	_setjmp.
---
 gcc/testsuite/gcc.dg/analyzer/setjmp-pr93378.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/gcc/testsuite/gcc.dg/analyzer/setjmp-pr93378.c b/gcc/testsuite/gcc.dg/analyzer/setjmp-pr93378.c
index 7934a40301d..73b94d4d36b 100644
--- a/gcc/testsuite/gcc.dg/analyzer/setjmp-pr93378.c
+++ b/gcc/testsuite/gcc.dg/analyzer/setjmp-pr93378.c
@@ -7,7 +7,7 @@  jmp_buf buf;
 int
 test (void)
 {
-  if (_setjmp (buf) != 0)
+  if (setjmp (buf) != 0)
     return 0;
 
   longjmp (buf, 1);