From: Martin Jambor <mjambor@suse.cz>
To: Jeff Law <law@redhat.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC] Assert DECL_ABSTRACT_ORIGIN is different from the decl itself
Date: Wed, 30 Nov 2016 13:09:00 -0000 [thread overview]
Message-ID: <20161130130918.n4e2rcvqnvzdwo2x@virgil.suse.cz> (raw)
In-Reply-To: <040f66b4-e86c-1ab3-964d-0a5cba95fab5@redhat.com>
Hi,
On Tue, Nov 29, 2016 at 10:17:02AM -0700, Jeff Law wrote:
> On 11/29/2016 03:13 AM, Richard Biener wrote:
> > On Mon, Nov 28, 2016 at 6:28 PM, Martin Jambor <mjambor@suse.cz> wrote:
> > > Hi Jeff,
> > >
> > > On Mon, Nov 28, 2016 at 08:46:05AM -0700, Jeff Law wrote:
> > > > On 11/28/2016 07:27 AM, Martin Jambor wrote:
> > > > > Hi,
> > > > >
> > > > > one of a number of symptoms of an otherwise unrelated HSA bug I've
> > > > > been debugging today is gcc crashing or hanging in the C++ pretty
> > > > > printer when attempting to emit a warning because dump_decl() ended up
> > > > > in an infinite recursion calling itself on the DECL_ABSTRACT_ORIGIN of
> > > > > the decl it was looking at, which was however the same thing. (It was
> > > > > set to itself on purpose in set_decl_origin_self as a part of final
> > > > > pass, the decl was being printed because it was itself an abstract
> > > > > origin of another one).
> > > > >
> > > > > If someone ever faces a similar problem, the following (untested)
> > > > > patch might save them a bit of time. I have eventually decided not to
> > > > > make it a checking-only assert because it is on a cold path and
> > > > > because at release-build optimization levels, the tail-call is
> > > > > optimized to a jump and thus an infinite loop if the described
> > > > > situation happens, and I suppose an informative ICE is better tan that
> > > > > even for users.
> > > > >
> > > > > What do you think? Would it be reasonable for trunk even now or
> > > > > should I queue it for the next stage1?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Martin
> > > > >
> > > > >
> > > > > gcc/cp/
> > > > >
> > > > > 2016-11-28 Martin Jambor <mjambor@suse.cz>
> > > > >
> > > > > * error.c (dump_decl): Add an assert that DECL_ABSTRACT_ORIGIN
> > > > > is not the decl itself.
> > > > Given it's on an error/debug path it ought to be plenty safe for now. What's
> > > > more interesting is whether or not DECL_ABSTRACT_ORIGIN can legitimately
> > > > point to itself and if so, how is that happening.
> > >
> > > Well, I tried to explain it in my original email but I also wanted to
> > > be as brief as possible, so perhaps it is necessary to elaborate a bit:
> > >
> > > There is a function set_decl_origin_self() in dwarf2out.c that does
> > > just that, sets DECL_ABSTRACT_ORIGIN to the decl itself, and its
> > > comment makes it clear that is intended (according to git blame, the
> > > whole comment and much of the implementation come from 1992, though ;-)
> > > The function is called from the "final" pass through dwarf2out_decl(),
> > > and gen_decl_die().
> > >
> > > So, for one reason or another, this is the intended behavior.
> > > Apparently, after that one is not supposed to be printing the decl
> > > name of such a "finished" a function. It is too bad however that this
> > > can happen if a "finished" function is itself an abstract origin of a
> > > different one, which is optimized and expanded only afterwards and you
> > > attempt to print its decl name, because it triggers printing the decl
> > > name of the finished function, in turn triggering the infinite
> > > recursion/loop. I am quite surprised that we have not hit this
> > > earlier (e.g. with warnings in IPA-CP clones) but perhaps there is a
> > > reason.
> > >
> > > I will append the patch to some bootstrap and testing run and commit
> > > it afterwards if it passes.
> >
> > Other users explicitely check for the self-reference when walking origins.
> I think that makes it pretty clear that we have to handle self-reference.
> So it seems that rather than an assert that we should just not walk down a
> self-referencing DECL_ABSTRACT_ORIGIN.
>
I'm not sure what you mean by "walk down." The code in dump_decl()
that deals with function decls is:
case FUNCTION_DECL:
if (! DECL_LANG_SPECIFIC (t))
{
if (DECL_ABSTRACT_ORIGIN (t))
dump_decl (pp, DECL_ABSTRACT_ORIGIN (t), flags);
else
pp_string (pp, M_("<built-in>"));
}
else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
dump_global_iord (pp, t);
else
dump_function_decl (pp, t, flags);
break;
I suppose that there are good reasons for treating
!DECL_LANG_SPECIFIC(t) specially and not pass it down to
dump_function_decl, even if DECL_ABSTRACT_ORIGIN (t) == t. But
printing <built-in>, though perhaps better than an ICE or hang, feels
also wrong and we already print it when we shouldn't (see PR 78589).
So I wonder what the options are... perhaps it seems that we can call
dump_function_name which starts with code handling
!DECL_LANG_SPECIFIC(t) cases, even instead of the weird <built-in>
thing?
I guess I'll give it a try later this week.
Thanks,
Martin
next prev parent reply other threads:[~2016-11-30 13:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-28 14:27 Martin Jambor
2016-11-28 15:46 ` Jeff Law
2016-11-28 17:28 ` Martin Jambor
2016-11-29 10:14 ` Richard Biener
2016-11-29 17:17 ` Jeff Law
2016-11-30 13:09 ` Martin Jambor [this message]
2016-12-01 16:10 ` Martin Jambor
2016-12-06 3:33 ` Jeff Law
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=20161130130918.n4e2rcvqnvzdwo2x@virgil.suse.cz \
--to=mjambor@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
--cc=richard.guenther@gmail.com \
/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).