From patchwork Sun Jul 5 12:07:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 50668 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9F166229FC for ; Sun, 5 Jul 2015 12:08:11 +0000 (UTC) Received: by wifm2 with SMTP id m2sf2585971wif.1 for ; Sun, 05 Jul 2015 05:08:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to :content-type:x-original-sender:x-original-authentication-results; bh=tt5rGpLdLUW76Yn5CL3eBEHGZEhcI/LL0th2IgeuG1U=; b=AFQhwEHlpa1jwERqHeXmjs42mpEoLBcwmiIl9jkr1yIpu9xrauECHuUFeUoO+84LdQ L0Sfg7DGI7Eep+YoS9mspWb05wsRYWK5RaBJd2aqJktBOfA0dVfo8Xo5sFwayxOtmMES FXyL0WkucKjFs0yMgJzrcYvKdcahK4y9xnWyfLrDiexGZgV5PXsnIhvjEcefSbuNGHaP U4rKM1DK/OkqS2h5BOQKD8OkTEOezcrxvUM+LiaQt7R+z1QIMVy4pYu/JGHAF3gPxN1M RtPXDoKY3bnOtylWU6IvzI084UIbscjoR6WzW2FOtYiRjQ8hOLcirKWCD0GooWyf0BN4 bCww== X-Gm-Message-State: ALoCoQkXjDB3p4E0UDMjCkdrS5Gos6aUbEmBjjlVCTVDiBP6r923JSYf4V4n2H0IwixPy513Ik+Z X-Received: by 10.112.181.37 with SMTP id dt5mr14162664lbc.10.1436098090757; Sun, 05 Jul 2015 05:08:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.228 with SMTP id h4ls612805lam.23.gmail; Sun, 05 Jul 2015 05:08:10 -0700 (PDT) X-Received: by 10.152.6.105 with SMTP id z9mr43534754laz.98.1436098090226; Sun, 05 Jul 2015 05:08:10 -0700 (PDT) Received: from mail-la0-x22c.google.com (mail-la0-x22c.google.com. [2a00:1450:4010:c03::22c]) by mx.google.com with ESMTPS id ef1si12417591lac.154.2015.07.05.05.08.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2015 05:08:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22c as permitted sender) client-ip=2a00:1450:4010:c03::22c; Received: by lagx9 with SMTP id x9so126215913lag.1 for ; Sun, 05 Jul 2015 05:08:09 -0700 (PDT) X-Received: by 10.112.55.207 with SMTP id u15mr44149780lbp.88.1436098089684; Sun, 05 Jul 2015 05:08:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1117941lbb; Sun, 5 Jul 2015 05:08:07 -0700 (PDT) X-Received: by 10.70.108.198 with SMTP id hm6mr34040709pdb.103.1436098086945; Sun, 05 Jul 2015 05:08:06 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ps1si23807776pdb.215.2015.07.05.05.08.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2015 05:08:06 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-402014-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 117341 invoked by alias); 5 Jul 2015 12:07:55 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 117328 invoked by uid 89); 5 Jul 2015 12:07:54 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f173.google.com Received: from mail-yk0-f173.google.com (HELO mail-yk0-f173.google.com) (209.85.160.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 05 Jul 2015 12:07:53 +0000 Received: by ykfy125 with SMTP id y125so127634241ykf.1 for ; Sun, 05 Jul 2015 05:07:51 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.129.74.135 with SMTP id x129mr53885740ywa.98.1436098071258; Sun, 05 Jul 2015 05:07:51 -0700 (PDT) Received: by 10.37.88.137 with HTTP; Sun, 5 Jul 2015 05:07:51 -0700 (PDT) Date: Sun, 5 Jul 2015 17:37:51 +0530 Message-ID: Subject: fix segfault in verify_flow_info() with -dx option From: Prathamesh Kulkarni To: gcc Patches , Richard Biener X-IsSubscribed: yes X-Original-Sender: prathamesh.kulkarni@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22c as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Hi, Passing -dx causes segmentation fault: Test case: void f(void) {} ./test.c: In function 'f': ../test.c:3:1: internal compiler error: Segmentation fault } ^ 0xab6baf crash_signal /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/toplev.c:366 0x694b14 verify_flow_info() /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/cfghooks.c:109 0x9f7e64 execute_function_todo /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/passes.c:1997 0x9f86eb execute_todo /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/passes.c:2042 Started with r210068. It looks like -dx causes cfun->cfg to be NULL, and hence the segfault in verify_flow_info(). The attached patch tries to fix it by adding a check to cfun->cfg before calling verify_flow_info() from execute_function_todo(). Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk ? Thank you, Prathamesh 2015-07-05 Prathamesh Kulkarni * passes.c (execute_function_todo): Check for cfun->cfg before calling verify_flow_info(). diff --git a/gcc/passes.c b/gcc/passes.c index 4966334..8362554 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -1965,7 +1965,8 @@ execute_function_todo (function *fn, void *data) /* IPA passes leave basic-blocks unsplit, so make sure to not trip on that. */ if ((cfun->curr_properties & PROP_cfg) - && !from_ipa_pass) + && !from_ipa_pass + && cfun->cfg) verify_flow_info (); if (current_loops && loops_state_satisfies_p (LOOP_CLOSED_SSA))