[binutils-gdb] gdb: restore nullptr check in compunit_symtab::find_call_site

Simon Marchi simark@sourceware.org
Tue Dec 3 19:19:42 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=22a7a2d12a81a4c4521d1d9996d06b7abf315acc

commit 22a7a2d12a81a4c4521d1d9996d06b7abf315acc
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Dec 3 10:52:18 2024 -0500

    gdb: restore nullptr check in compunit_symtab::find_call_site
    
    Commit de2b4ab50de ("Convert dwarf2_cu::call_site_htab to new hash
    table") removed this nullptr check for no good reason.  This causes a
    crash if `m_call_site_htab` is not set, as shown in PR 32410.  My guess
    is that when doing this change, I tried to make `m_call_site_htab` not a
    pointer, removed this check, then realized it wasn't so obvious, and
    forgot to re-add the check.
    
    Change-Id: I455e00cdc0519dfb412dc7826d17a839b77aae69
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32410
    Approved-By: Tom Tromey <tom@tromey.com>
    Approved-By: Tom de Vries <tdevries@suse.de>

Diff:
---
 gdb/symtab.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index edc19ff5c15..30c22dcea38 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -396,6 +396,9 @@ linetable_entry::pc (const struct objfile *objfile) const
 call_site *
 compunit_symtab::find_call_site (CORE_ADDR pc) const
 {
+  if (m_call_site_htab == nullptr)
+    return nullptr;
+
   CORE_ADDR delta = this->objfile ()->text_section_offset ();
 
   if (auto it = m_call_site_htab->find (static_cast<unrelocated_addr> (pc - delta));


More information about the Gdb-cvs mailing list