* [PATCH] rtl_dump_bb: fix segfault when reporting internal error
@ 2020-11-26 19:24 Ilya Leoshkevich
2020-11-30 1:14 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Ilya Leoshkevich @ 2020-11-26 19:24 UTC (permalink / raw)
To: gcc-patches
Bootstrapped and regtested on x86_64-redhat-linux and
s390x-redhat-linux. Ok for master?
During ICE reporting, sometimes rtl_dump_bb is called on partially
initialized basic blocks. This produces another ICE, obscuring the
original problem.
Fix by checking that that basic blocks are initialized before touching
their bb_infos.
gcc/ChangeLog:
2020-11-25 Ilya Leoshkevich <iii@linux.ibm.com>
* cfgrtl.c (rtl_bb_info_initialized_p): New function.
(rtl_dump_bb): Use rtl_bb_info_initialized_p before accessing bb
insns.
---
gcc/cfgrtl.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 45d84d39b22..5e909e25882 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -97,6 +97,7 @@ static basic_block rtl_split_block (basic_block, void *);
static void rtl_dump_bb (FILE *, basic_block, int, dump_flags_t);
static int rtl_verify_flow_info_1 (void);
static void rtl_make_forwarder_block (edge);
+static bool rtl_bb_info_initialized_p (basic_block bb);
\f
/* Return true if NOTE is not one of the ones that must be kept paired,
so that we may simply delete it. */
@@ -2149,7 +2150,8 @@ rtl_dump_bb (FILE *outf, basic_block bb, int indent, dump_flags_t flags)
putc ('\n', outf);
}
- if (bb->index != ENTRY_BLOCK && bb->index != EXIT_BLOCK)
+ if (bb->index != ENTRY_BLOCK && bb->index != EXIT_BLOCK
+ && rtl_bb_info_initialized_p (bb))
{
rtx_insn *last = BB_END (bb);
if (last)
@@ -5135,6 +5137,12 @@ init_rtl_bb_info (basic_block bb)
bb->il.x.rtl = ggc_cleared_alloc<rtl_bb_info> ();
}
+static bool
+rtl_bb_info_initialized_p (basic_block bb)
+{
+ return bb->il.x.rtl;
+}
+
/* Returns true if it is possible to remove edge E by redirecting
it to the destination of the other edge from E->src. */
--
2.25.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] rtl_dump_bb: fix segfault when reporting internal error
2020-11-26 19:24 [PATCH] rtl_dump_bb: fix segfault when reporting internal error Ilya Leoshkevich
@ 2020-11-30 1:14 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2020-11-30 1:14 UTC (permalink / raw)
To: Ilya Leoshkevich, gcc-patches
On 11/26/20 12:24 PM, Ilya Leoshkevich via Gcc-patches wrote:
> Bootstrapped and regtested on x86_64-redhat-linux and
> s390x-redhat-linux. Ok for master?
>
>
>
> During ICE reporting, sometimes rtl_dump_bb is called on partially
> initialized basic blocks. This produces another ICE, obscuring the
> original problem.
>
> Fix by checking that that basic blocks are initialized before touching
> their bb_infos.
>
> gcc/ChangeLog:
>
> 2020-11-25 Ilya Leoshkevich <iii@linux.ibm.com>
>
> * cfgrtl.c (rtl_bb_info_initialized_p): New function.
> (rtl_dump_bb): Use rtl_bb_info_initialized_p before accessing bb
> insns.
I think reality is that these routines are never going to be 100% safe
in terms of not ICEing themselves (after all, the ICE might be an
internal inconsistency in the RTL IL itself), this seems like a
reasonable amount of sanity checking.
OK.
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-30 1:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26 19:24 [PATCH] rtl_dump_bb: fix segfault when reporting internal error Ilya Leoshkevich
2020-11-30 1:14 ` Jeff Law
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).