public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/27981] [gdb/symtab] CU importing itself causes gdb to segfault
Date: Wed, 29 Jun 2022 14:53:00 +0000	[thread overview]
Message-ID: <bug-27981-4717-hwBfQEv8YO@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27981-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27981

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Ad-hoc fixes to make the test-case pass:
...
diff --git a/gdb/block.c b/gdb/block.c
index 26126f5b76f..94feeb0f87c 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -488,7 +488,7 @@ initialize_block_iterator (const struct block *block,

   /* If this is an included symtab, find the canonical includer and
      use it instead.  */
-  while (cu->user != NULL)
+  while (cu->user != NULL && cu->user != cu)
     cu = cu->user;

   /* Putting this check here simplifies the logic of the iterator
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a36f25f4e62..9859328c276 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -18258,6 +18258,9 @@ cooked_indexer::index_imported_unit (cutu_reader
*reader,
   dwarf2_per_objfile *per_objfile = reader->cu->per_objfile;
   cutu_reader *new_reader = ensure_cu_exists (reader, per_objfile, sect_off,
                                              is_dwz, true);
+  if (new_reader == reader)
+    return info_ptr;
+
   if (new_reader != nullptr)
     {
       index_dies (new_reader, new_reader->info_ptr, nullptr, false);
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-06-29 14:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14 14:56 [Bug symtab/27981] New: " vries at gcc dot gnu.org
2021-06-14 14:59 ` [Bug symtab/27981] " vries at gcc dot gnu.org
2022-06-29 14:53 ` vries at gcc dot gnu.org [this message]
2022-06-29 15:29 ` vries at gcc dot gnu.org
2022-07-04 18:35 ` tromey at sourceware dot org
2022-07-04 18:36 ` tromey at sourceware dot org

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-27981-4717-hwBfQEv8YO@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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).