From patchwork Wed Jan 22 20:36:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1227424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518067-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=efxtg+We; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=V8CLhnJr; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 482xz01Kt2z9sQp for ; Thu, 23 Jan 2020 07:36:57 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=VV+KCOnzgCeLYcOHw33WsEEB9cuCRXnNWmLoAlQSROj2mhEUPf6ry AXKn/jO5daFxLyb60W+jWCY6k2WeWjz+nGrsfTi2l8bU+LNCThWnIBo2RVUTIHhr WQqYkBWygUdek9HnsqHmz6t8COQNR/ukCJBzQDfBKtlQDVs5q8Q4Dc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=mO2qU+H88HNwUgBh0VVBlII/APg=; b=efxtg+We5XFWSoryxj/09nNsKWLb r0DHT1Pt7ptZd/sc169/E83B30iWWGwBvRE+5PzqH6NG23DjbueuLx3Ma9s4Z6Y7 ClYLkO4PaK7BdgVqWPIhPu2NsZrwcxKDYQRqsVuPT3QEDUij+p72b6u3K4q8SuAW FAu79Q/vG3Ebuc0= Received: (qmail 42244 invoked by alias); 22 Jan 2020 20:36:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 42235 invoked by uid 89); 22 Jan 2020 20:36:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Jan 2020 20:36:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579725408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AgUxSDO6loypAS6kU63LWQkJBcTWYqXs+MuGRfN8s4M=; b=V8CLhnJrvfEm+MaZuy+ovoBWDtxfKfPn7TpWsxuyToOyAniSr607668kWacdKodAGyqmVH 1PwahcLhwgEdlleD59gxJ0FvfrbkJ2QI3pZ30XqI/rc4kpbnbC80cMvFssCM9CH7r9UrUP xDOXu1kQCDllhvERVzePRxKSFE6AVro= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-82-usWNQ_fMNYiwzHkcQt5XJQ-1; Wed, 22 Jan 2020 15:36:46 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30741800D41 for ; Wed, 22 Jan 2020 20:36:45 +0000 (UTC) Received: from t470.redhat.com (ovpn-117-41.phx2.redhat.com [10.3.117.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id C161A845A5; Wed, 22 Jan 2020 20:36:44 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed] analyzer: fix usage of "_setjmp" in test for PR 93378 Date: Wed, 22 Jan 2020 15:36:40 -0500 Message-Id: <20200122203640.30702-1-dmalcolm@redhat.com> In-Reply-To: <20200122195602.24445-1-dmalcolm@redhat.com> References: <20200122195602.24445-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes 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 . > > 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 > + > +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 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(-) 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);