public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix IPA crash in libgccjit
       [not found] <1b1d2bd3-3536-5525-1660-09a7b18a9ecd@gmail.com>
@ 2018-01-01  0:00 ` David Malcolm
  2018-01-01  0:00   ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: David Malcolm @ 2018-01-01  0:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: jit, David Malcolm

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix IPA crash in libgccjit
  2018-01-01  0:00 ` [PATCH] Fix IPA crash in libgccjit David Malcolm
@ 2018-01-01  0:00   ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2018-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm; +Cc: GCC Patches, jit

On Thu, Jun 21, 2018 at 1:07 AM David Malcolm <dmalcolm@redhat.com> wrote:
>
> 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?

OK.

RIchard.

> 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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-21  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1b1d2bd3-3536-5525-1660-09a7b18a9ecd@gmail.com>
2018-01-01  0:00 ` [PATCH] Fix IPA crash in libgccjit David Malcolm
2018-01-01  0:00   ` Richard Biener

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).