Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [committed][gdb] Fix segfault in solib_contains_address_p
Date: Wed, 14 Oct 2020 13:20:45 +0200	[thread overview]
Message-ID: <20201014112044.GA1927@delia> (raw)

Hi,

Starting commit bb2a67773c "Use a std::vector in target_section_table" we run
into:
...
ERROR: GDB process no longer exists
GDB process exited with wait status 22239 exp12 0 0 CHILDKILLED SIGABRT
UNRESOLVED: gdb.base/exec-invalid-sysroot.exp: continue to exec catchpoint
...
which reproduces as:
...
Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
solib_contains_address_p (address=4196111, solib=0x1dd9970)
    at /home/vries/gdb_versions/devel/src/gdb/solib.c:1120
1120      for (target_section &p : solib->sections->sections)
(gdb) p solib->sections->sections
Cannot access memory at address 0x0
...

Fix this by handling solib->sections == nullptr in solib_contains_address_p.

Build and reg-tested on x86_64-linux.

Committed to trunk.

Thanks,
- Tom

[gdb] Fix segfault in solib_contains_address_p

gdb/ChangeLog:

2020-10-14  Tom de Vries  <tdevries@suse.de>

	PR gdb/26733
	* solib.c (solib_contains_address_p): Handle
	'solib->sections == nullptr'.

---
 gdb/solib.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/solib.c b/gdb/solib.c
index b4864429e9..28f6a4ecbf 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1113,6 +1113,9 @@ bool
 solib_contains_address_p (const struct so_list *const solib,
 			  CORE_ADDR address)
 {
+  if (solib->sections == nullptr)
+    return false;
+
   for (target_section &p : *solib->sections)
     if (p.addr <= address && address < p.endaddr)
       return true;

                 reply	other threads:[~2020-10-14 11:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20201014112044.GA1927@delia \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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