public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: jit@gcc.gnu.org,	David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH] Fix IPA crash in libgccjit
Date: Mon, 01 Jan 2018 00:00:00 -0000	[thread overview]
Message-ID: <1529538619-47020-1-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <1b1d2bd3-3536-5525-1660-09a7b18a9ecd@gmail.com>

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

       reply	other threads:[~2018-06-20 23:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1b1d2bd3-3536-5525-1660-09a7b18a9ecd@gmail.com>
2018-01-01  0:00 ` David Malcolm [this message]
2018-01-01  0:00   ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1529538619-47020-1-git-send-email-dmalcolm@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).