public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] PR25078, stack overflow in function find_abstract_instance
Date: Mon, 14 Oct 2019 13:42:00 -0000	[thread overview]
Message-ID: <063c511bd79281f33fd33f0964541a73511b9e2b@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 063c511bd79281f33fd33f0964541a73511b9e2b ***

commit 063c511bd79281f33fd33f0964541a73511b9e2b
Author:     Alan Modra <amodra@gmail.com>
AuthorDate: Wed Oct 9 00:07:29 2019 +1030
Commit:     Alan Modra <amodra@gmail.com>
CommitDate: Wed Oct 9 00:20:28 2019 +1030

    PR25078, stack overflow in function find_abstract_instance
    
            PR 25078
            * dwarf2.c (find_abstract_instance): Delete orig_info_ptr, add
            recur_count.  Error on recur_count reaching 100 rather than
            info_ptr matching orig_info_ptr.  Adjust calls.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 6062d38a28..cf5b372860 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2019-10-08  Alan Modra  <amodra@gmail.com>
+
+	PR 25078
+	* dwarf2.c (find_abstract_instance): Delete orig_info_ptr, add
+	recur_count.  Error on recur_count reaching 100 rather than
+	info_ptr matching orig_info_ptr.  Adjust calls.
+
 2019-10-07  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
 
 	* elf32-msp430.c (elf32_msp430_merge_mspabi_attributes): Rename to..
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 575b082e1d..d39f4fdfe4 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -2812,13 +2812,13 @@ static bfd_boolean comp_unit_maybe_decode_line_info (struct comp_unit *,
 						     struct dwarf2_debug *);
 
 static bfd_boolean
-find_abstract_instance (struct comp_unit *   unit,
-			bfd_byte *           orig_info_ptr,
-			struct attribute *   attr_ptr,
-			const char **        pname,
-			bfd_boolean *        is_linkage,
-			char **              filename_ptr,
-			int *                linenumber_ptr)
+find_abstract_instance (struct comp_unit *unit,
+			struct attribute *attr_ptr,
+			unsigned int recur_count,
+			const char **pname,
+			bfd_boolean *is_linkage,
+			char **filename_ptr,
+			int *linenumber_ptr)
 {
   bfd *abfd = unit->abfd;
   bfd_byte *info_ptr;
@@ -2829,6 +2829,14 @@ find_abstract_instance (struct comp_unit *   unit,
   struct attribute attr;
   const char *name = NULL;
 
+  if (recur_count == 100)
+    {
+      _bfd_error_handler
+	(_("DWARF error: abstract instance recursion detected"));
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
   /* DW_FORM_ref_addr can reference an entry in a different CU. It
      is an offset from the .debug_info section, not the current CU.  */
   if (attr_ptr->form == DW_FORM_ref_addr)
@@ -2962,15 +2970,6 @@ find_abstract_instance (struct comp_unit *   unit,
 					 info_ptr, info_ptr_end);
 	      if (info_ptr == NULL)
 		break;
-	      /* It doesn't ever make sense for DW_AT_specification to
-		 refer to the same DIE.  Stop simple recursion.  */
-	      if (info_ptr == orig_info_ptr)
-		{
-		  _bfd_error_handler
-		    (_("DWARF error: abstract instance recursion detected"));
-		  bfd_set_error (bfd_error_bad_value);
-		  return FALSE;
-		}
 	      switch (attr.name)
 		{
 		case DW_AT_name:
@@ -2984,7 +2983,7 @@ find_abstract_instance (struct comp_unit *   unit,
 		    }
 		  break;
 		case DW_AT_specification:
-		  if (!find_abstract_instance (unit, info_ptr, &attr,
+		  if (!find_abstract_instance (unit, &attr, recur_count + 1,
 					       &name, is_linkage,
 					       filename_ptr, linenumber_ptr))
 		    return FALSE;
@@ -3200,7 +3199,7 @@ scan_unit_for_symbols (struct comp_unit *unit)
 
 		case DW_AT_abstract_origin:
 		case DW_AT_specification:
-		  if (!find_abstract_instance (unit, info_ptr, &attr,
+		  if (!find_abstract_instance (unit, &attr, 0,
 					       &func->name,
 					       &func->is_linkage,
 					       &func->file,


             reply	other threads:[~2019-10-14 13:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 13:42 gdb-buildbot [this message]
2019-10-14 13:42 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2019-10-14 15:10 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot
2019-10-14 15:59 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2019-10-20 10:25 ` Failures on Fedora-i686, " gdb-buildbot
2019-10-20 11:14 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2019-10-20 12:09 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2019-10-20 12:52 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2019-10-20 13:40 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

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=063c511bd79281f33fd33f0964541a73511b9e2b@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.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).