diff mbox series

Fix stack overflow with autofdo (PR83355)

Message ID 20171211070143.26129-1-andi@firstfloor.org
State New
Headers show
Series Fix stack overflow with autofdo (PR83355) | expand

Commit Message

Andi Kleen Dec. 11, 2017, 7:01 a.m. UTC
From: Andi Kleen <ak@linux.intel.com>

g++.dg/bprob* is failing currently with autofdo.

Running in gdb shows that there is a very deep recursion in get_index_by_decl until it
overflows the stack.

This patch seems to fix it (but not sure why the abstract origin would point to
itself)

Passes bootstrap and testing on x86_64-linux

gcc/:
2017-12-10  Andi Kleen  <ak@linux.intel.com>

	PR gcov-profile/83355
	* auto-profile.c (string_table::get_index_by_decl): Don't
	recurse when abstract origin points to itself.
---
 gcc/auto-profile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Biener Dec. 11, 2017, 3:28 p.m. UTC | #1
On Mon, Dec 11, 2017 at 8:01 AM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> g++.dg/bprob* is failing currently with autofdo.
>
> Running in gdb shows that there is a very deep recursion in get_index_by_decl until it
> overflows the stack.
>
> This patch seems to fix it (but not sure why the abstract origin would point to
> itself)
>
> Passes bootstrap and testing on x86_64-linux
Ok.

Richard.

> gcc/:
> 2017-12-10  Andi Kleen  <ak@linux.intel.com>
>
>         PR gcov-profile/83355
>         * auto-profile.c (string_table::get_index_by_decl): Don't
>         recurse when abstract origin points to itself.
> ---
>  gcc/auto-profile.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
> index 5134a795331..403709bad6b 100644
> --- a/gcc/auto-profile.c
> +++ b/gcc/auto-profile.c
> @@ -477,7 +477,7 @@ string_table::get_index_by_decl (tree decl) const
>    ret = get_index (lang_hooks.dwarf_name (decl, 0));
>    if (ret != -1)
>      return ret;
> -  if (DECL_ABSTRACT_ORIGIN (decl))
> +  if (DECL_ABSTRACT_ORIGIN (decl) && DECL_ABSTRACT_ORIGIN (decl) != decl)
>      return get_index_by_decl (DECL_ABSTRACT_ORIGIN (decl));
>
>    return -1;
> --
> 2.15.1
>
diff mbox series

Patch

diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index 5134a795331..403709bad6b 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -477,7 +477,7 @@  string_table::get_index_by_decl (tree decl) const
   ret = get_index (lang_hooks.dwarf_name (decl, 0));
   if (ret != -1)
     return ret;
-  if (DECL_ABSTRACT_ORIGIN (decl))
+  if (DECL_ABSTRACT_ORIGIN (decl) && DECL_ABSTRACT_ORIGIN (decl) != decl)
     return get_index_by_decl (DECL_ABSTRACT_ORIGIN (decl));
 
   return -1;