From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 38416 invoked by alias); 20 Jun 2018 23:07:05 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 38393 invoked by uid 89); 20 Jun 2018 23:07:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=UD:ipa-cp.c, ipa-cp.c, ipacpc, sk:test-fa X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Jun 2018 23:07:03 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5B7681DEB; Wed, 20 Jun 2018 23:07:01 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-12.phx2.redhat.com [10.3.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBC1A10018FF; Wed, 20 Jun 2018 23:07:00 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: jit@gcc.gnu.org, David Malcolm Subject: [PATCH] Fix IPA crash in libgccjit Date: Mon, 01 Jan 2018 00:00:00 -0000 Message-Id: <1529538619-47020-1-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1b1d2bd3-3536-5525-1660-09a7b18a9ecd@gmail.com> References: <1b1d2bd3-3536-5525-1660-09a7b18a9ecd@gmail.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 20 Jun 2018 23:07:01 +0000 (UTC) X-IsSubscribed: yes X-SW-Source: 2018-q2/txt/msg00006.txt.bz2 All/most of the jit.dg testcases are segfaulting on cleanup of the 2nd in-process iteration: PATH=.:$PATH LD_LIBRARY_PATH=. LIBRARY_PATH=. \ gdb --args \ testsuite/jit/test-factorial.c.exe Starting program: /home/david/coding-3/gcc-git-static-analysis/build/gcc/testsuite/jit/test-factorial.c.exe PASSED: test-factorial.c.exe iteration 1 of 5: set_up_logging: logfile is non-null NOTE: test-factorial.c.exe iteration 1 of 5: writing reproducer to /home/david/coding-3/gcc-git-static-analysis/build/gcc/testsuite/jit/test-factorial.c.exe.reproducer.c Detaching after fork from child process 35787. Detaching after fork from child process 35789. PASSED: test-factorial.c.exe iteration 1 of 5: verify_code: result is non-null PASSED: test-factorial.c.exe iteration 1 of 5: verify_code: my_factorial is non-null NOTE: my_factorial returned: 3628800 PASSED: test-factorial.c.exe iteration 1 of 5: verify_code: actual: val == expected: 3628800 PASSED: test-factorial.c.exe iteration 2 of 5: set_up_logging: logfile is non-null NOTE: test-factorial.c.exe iteration 2 of 5: writing reproducer to /home/david/coding-3/gcc-git-static-analysis/build/gcc/testsuite/jit/test-factorial.c.exe.reproducer.c Program received signal SIGSEGV, Segmentation fault. 0x00007ffff71abc75 in ipcp_driver () at ../../src/gcc/ipa-cp.c:5091 5091 delete edge_clone_summaries; This appears to be due to recent(?) IPA changes that appear to assume that the IPA code is only initialized and cleaned up once. This patch fixes the crashes: Changes to jit.sum ------------------ FAIL: 65->0 (-65) PASS: 3186->10290 (+7104) UNRESOLVED: 1->0 (-1) Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. OK for trunk? gcc/ChangeLog: * ipa-cp.c (ipcp_driver): Set edge_clone_summaries to NULL after deleting it. * ipa-reference.c (ipa_reference_c_finalize): Delete ipa_ref_opt_sum_summaries and set it to NULL. --- gcc/ipa-cp.c | 1 + gcc/ipa-reference.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index c192e84..42dd4cc 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -5089,6 +5089,7 @@ ipcp_driver (void) /* Free all IPCP structures. */ free_toporder_info (&topo); delete edge_clone_summaries; + edge_clone_summaries = NULL; ipa_free_all_structures_after_ipa_cp (); if (dump_file) fprintf (dump_file, "\nIPA constant propagation end\n"); diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 9a9e94c..43bbdae 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -1230,6 +1230,12 @@ make_pass_ipa_reference (gcc::context *ctxt) void ipa_reference_c_finalize (void) { + if (ipa_ref_opt_sum_summaries != NULL) + { + delete ipa_ref_opt_sum_summaries; + ipa_ref_opt_sum_summaries = NULL; + } + if (ipa_init_p) { bitmap_obstack_release (&optimization_summary_obstack); -- 1.8.5.3