I am terribly sorry for my typo of wrong PR #, it should be 102624.
Please ignore this email thread and I resend the patch in next email
with correct subject:
[PATCH] c++: Comment out announce_function to prevent ICE [PR102624]

Once again my apologies for spam.

On Fri, Oct 8, 2021 at 12:31 AM qingzhe huang <nickhuan...@gmail.com> wrote:
>
> This "announce_function" is not a purely readonly
> function. Instead it calls tsubst which modifies
> global variable "current_function_decl". If it is
> placed at parser code directory level, recursion
> might happen and set/reset variable might interleave
> and can cause ICE. No test case is provided because
> this segment fault only occurs when compiler option
> "-quiet" is not set which is usually set by driver.
> That is why usual testcases cannot expose this issue.
> Even though this issue usually doesn't affect endusers,
> however, it is a headache for development.
>
> gcc/cp/ChangeLog:
>         PR c++/102426
>         * decl.c (start_preparsed_function): Comment
>         out announce_function.
>         (emit_coro_helper): Comment out
>         announce_function.
>
> gcc/ChangeLog:
>         PR c++/102426
>         * toplev.c (get_src_pwd): Add comment
>         to note announce_function usage.
>
> Signed-off-by: qingzhe huang <nickhuan...@gmail.com>
> ---
>  gcc/cp/decl.c | 4 ----
>  gcc/toplev.c  | 5 ++++-
>  2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> index 2d30c790b93..94d3a2c1cba 100644
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -16904,9 +16904,6 @@ start_preparsed_function (tree decl1, tree attrs, int 
> flags)
>       where store_parm_decls will find them.  */
>    tree current_function_parms = DECL_ARGUMENTS (decl1);
>
> -  /* Let the user know we're compiling this function.  */
> -  announce_function (decl1);
> -
>    gcc_assert (DECL_INITIAL (decl1));
>
>    /* This function may already have been parsed, in which case just
> @@ -17472,7 +17469,6 @@ emit_coro_helper (tree helper)
>    current_function_decl = helper;
>    begin_scope (sk_function_parms, NULL);
>    store_parm_decls (DECL_ARGUMENTS (helper));
> -  announce_function (helper);
>    allocate_struct_function (helper, false);
>    cfun->language = ggc_cleared_alloc<language_function> ();
>    poplevel (1, 0, 1);
> diff --git a/gcc/toplev.c b/gcc/toplev.c
> index 1bb1794be96..4a3ca1aef4a 100644
> --- a/gcc/toplev.c
> +++ b/gcc/toplev.c
> @@ -221,7 +221,10 @@ get_src_pwd (void)
>  }
>
>  /* Called when the start of a function definition is parsed,
> -   this function prints on stderr the name of the function.  */
> +   this function prints on stderr the name of the function.
> +   NOTE: Do not use this function at directory gcc/cp level
> +   or below because it might recurse and interleave with
> +   function frame parsing which can cause crash. */
>  void
>  announce_function (tree decl)
>  {
> --
> 2.17.1
>

Reply via email to