From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: Jan Hubicka <hubicka@ucw.cz>,
jit@gcc.gnu.org, David Malcolm <dmalcolm@redhat.com>
Subject: [committed] Fix segfault in free_growth_caches (PR jit/80954)
Date: Fri, 02 Jun 2017 17:13:00 -0000 [thread overview]
Message-ID: <1496425523-7546-1-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <20170522153754.GE21448@kam.mff.cuni.cz>
r248336 added these lines to free_growth_caches
if (edge_removal_hook_holder)
symtab->remove_edge_removal_hook (edge_removal_hook_holder);
which broke the JIT; attempts to compile more than one time
within a single process segfault here:
305 symbol_table::remove_edge_removal_hook (cgraph_edge_hook_list *entry)
306 {
307 cgraph_edge_hook_list **ptr = &m_first_edge_removal_hook;
308
309 while (*ptr != entry)
>>310 ptr = &(*ptr)->next;
311 *ptr = entry->next;
312 free (entry);
313 }
(gdb) p ptr
$3 = (cgraph_edge_hook_list **) 0x10
(gdb) bt
#0 symbol_table::remove_edge_removal_hook (this=0x7fffeef83200, entry=0x664c90) at ../../src/gcc/cgraph.c:310
#1 0x00007ffff6a03e2c in free_growth_caches () at ../../src/gcc/ipa-inline-analysis.c:113
#2 0x00007ffff73e7bd9 in inline_small_functions () at ../../src/gcc/ipa-inline.c:2059
#3 ipa_inline () at ../../src/gcc/ipa-inline.c:2417
[...]
The root cause is that initialize_growth_caches lazily adds
edge_removal_hook_holder to the symtab:
99 if (!edge_removal_hook_holder)
100 edge_removal_hook_holder =
101 symtab->add_edge_removal_hook (&inline_edge_removal_hook, NULL);
but free_growth_caches removes it without NULL-ing it:
112 if (edge_removal_hook_holder)
113 symtab->remove_edge_removal_hook (edge_removal_hook_holder);
Hence on the second call to free_growth_caches, it attempts to remove
the edge_removal_hook_holder from the 1st iteration's
initialize_growth_caches, which isn't present in the 2nd iteration's
symtab.
Hence the edge_removal_hook_holder isn't present, and
symtab::remove_edge_removal_hook, relying on it as a sentinel value,
reads through ((cgraph_edge_hook_list *)NULL)->next.
This patch fixes the segfault by resetting it to NULL when removing it.
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.
Restores jit.sum from:
# of expected passes 2892
# of unexpected failures 61
# of unresolved testcases 1
to:
# of expected passes 3202
Committed to trunk as r248841, under the "obvious" rule.
gcc/ChangeLog:
PR jit/80954
* ipa-inline-analysis.c (free_growth_caches): Set
edge_removal_hook_holder to NULL after removing it.
---
gcc/ipa-inline-analysis.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index f562ca5..9f7b2a1 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -110,7 +110,10 @@ void
free_growth_caches (void)
{
if (edge_removal_hook_holder)
- symtab->remove_edge_removal_hook (edge_removal_hook_holder);
+ {
+ symtab->remove_edge_removal_hook (edge_removal_hook_holder);
+ edge_removal_hook_holder = NULL;
+ }
edge_growth_cache.release ();
}
--
1.8.5.3
prev parent reply other threads:[~2017-06-02 17:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-22 15:43 Break ipa-inline-analysis Jan Hubicka
2017-06-02 17:13 ` David Malcolm [this message]
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=1496425523-7546-1-git-send-email-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--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).