public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nickhuang99 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/102624] testcase lambda-uneval11.C causes cc1plus  segment fault
Date: Thu, 07 Oct 2021 10:46:56 +0000	[thread overview]
Message-ID: <bug-102624-4-gC4nA0pLvE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102624-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102624

--- Comment #2 from qingzhe huang <nickhuang99 at hotmail dot com> ---
(In reply to Richard Biener from comment #1)

> so it looks like some diagnostics affect current_function_decl, the key
> is omitting -quiet from the command-line that's usually added by the driver.

That is absolutely correct. However, I think the real danger is the
"announce_function" which is the root cause. The name and behavior makes it
look like a harmless-readonly debug output. However, it is effectively doing
not only recursing itself, but sidelines by calling "tsubt" which eventually
set "current_function_decl" back-and-forth. So, my fix is to comment out this
"announce_function" below directory "cp" level because it might recurse itself
and interleave with the set/reset "current_function_decl". 

Does anybody depend on the result of this "announce_function"? Driver? Plugin? 

Also I want to point out that any debug method using debug printf of format
"%F" will suffer the similar issue because they are similar to
"announce_function". I personally debug using a lot of this format and it
drives me crazy when these seemingly-harmless print/warning function cause
crash. Somebody needs to write some really "readonly" debug output helper
functions for developers!

I may prepare a patch if no objections. 

BTW, this issue is hidden by option "-quiet" because it suppresses
"announce_function" output.


#0  announce_function (decl=0x7ffff73ab700) at
../../gcc-10.2.0/gcc/toplev.c:230
#1  0x0000000000a03d26 in start_preparsed_function (decl1=0x7ffff73ab700,
attrs=0x0, flags=3)
    at ../../gcc-10.2.0/gcc/cp/decl.c:16291
#2  0x0000000000a4cc75 in start_lambda_function (fco=0x7ffff73ab700,
lambda_expr=0x7ffff7399cc0)
    at ../../gcc-10.2.0/gcc/cp/lambda.c:1425
#3  0x0000000000b25f8f in tsubst_lambda_expr (t=0x7ffff7399480,
args=0x7ffff7383aa0, complain=0, 
    in_decl=0x7ffff738b100) at ../../gcc-10.2.0/gcc/cp/pt.c:19086
#4  0x0000000000b2aa76 in tsubst_copy_and_build (t=0x7ffff7399480,
args=0x7ffff7383aa0, complain=0, in_decl=0x0, 
    function_p=false, integral_constant_expression_p=false) at
../../gcc-10.2.0/gcc/cp/pt.c:20511
#5  0x0000000000b1be1b in tsubst (t=0x7ffff739c000, args=0x7ffff7383aa0,
complain=0, in_decl=0x0)
    at ../../gcc-10.2.0/gcc/cp/pt.c:15936
#6  0x0000000000a20637 in dump_template_bindings (pp=0x343cfc0
<actual_pretty_printer>, parms=0x0, 
    args=0x7ffff7383aa0, typenames=0x7ffff73a67f8) at
../../gcc-10.2.0/gcc/cp/error.c:416
#7  0x0000000000a23b94 in dump_substitution (pp=0x343cfc0
<actual_pretty_printer>, t=0x7ffff726b400, 
    template_parms=0x7ffff73827f8, template_args=0x7ffff7383aa0, flags=4) at
../../gcc-10.2.0/gcc/cp/error.c:1562
#8  0x0000000000a24622 in dump_function_decl (pp=0x343cfc0
<actual_pretty_printer>, t=0x7ffff726b400, flags=4)
    at ../../gcc-10.2.0/gcc/cp/error.c:1720
#9  0x0000000000a230b0 in dump_decl (pp=0x343cfc0 <actual_pretty_printer>,
t=0x7ffff73a3300, flags=4)
    at ../../gcc-10.2.0/gcc/cp/error.c:1292
#10 0x0000000000a27805 in decl_as_string (decl=0x7ffff73a3300, flags=4) at
../../gcc-10.2.0/gcc/cp/error.c:2995
#11 0x0000000000a278dd in lang_decl_name (decl=0x7ffff73a3300, v=2,
translate=false)
    at ../../gcc-10.2.0/gcc/cp/error.c:3029
#12 0x0000000000b78f8a in cxx_printable_name_internal (decl=0x7ffff73a3300,
v=2, translate=false)
    at ../../gcc-10.2.0/gcc/cp/tree.c:2596
#13 0x0000000000b7900b in cxx_printable_name (decl=0x7ffff73a3300, v=2) at
../../gcc-10.2.0/gcc/cp/tree.c:2605
#14 0x000000000139c9cf in announce_function (decl=0x7ffff73a3300) at
../../gcc-10.2.0/gcc/toplev.c:236

      parent reply	other threads:[~2021-10-07 10:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 22:06 [Bug c++/102624] New: " nickhuang99 at hotmail dot com
2021-10-06  8:51 ` [Bug c++/102624] " rguenth at gcc dot gnu.org
2021-10-07 10:46 ` nickhuang99 at hotmail dot com [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=bug-102624-4-gC4nA0pLvE@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).