This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix stack overflow with autofdo (PR83355)


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(-)

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]