[RFC][PATCH] Fix sigsegv when a process is attached to GDB on Solaris

Libor Bukata libor.bukata@oracle.com
Mon Feb 15 15:26:07 GMT 2021


>From 4ce6efa21e47156589dbf219d1121f6a86448704 Mon Sep 17 00:00:00 2001
From: Libor Bukata <libor.bukata@oracle.com>
Date: Mon, 15 Feb 2021 15:14:44 +0100
Subject: [PATCH] Fix sigsegv when a process is attached to GDB on Solaris

Started with GDB 10.1, the attach to a process was crashing
because the_procfs_target variable had not been initialized
with a valid process_stratum_target structure. To fix the
issue, we extract a valid stratum from the current inferior.

gdb/ChangeLog:

2021-02-15  Libor Bukata <libor.bukata@oracle.com>

        * procfs.c: Fix an invalid access to process stratum.
---
 gdb/procfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/procfs.c b/gdb/procfs.c
index e73faa8d41d..79edad6932d 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -1877,7 +1877,7 @@ do_attach (ptid_t ptid)
 
   /* Add it to gdb's thread list.  */
   ptid = ptid_t (pi->pid, lwpid, 0);
-  thread_info *thr = add_thread (&the_procfs_target, ptid);
+  thread_info *thr = add_thread (inf->process_target(), ptid);
   switch_to_thread (thr);
 }
 
-- 
2.26.2

Hello,

the patch fixes the crash when GDB is attached to a process on Solaris.

Testing:
- Attach to a process on Solaris x86/sparc
- Unit tests on Fedora Linux; no new regressions

Please let me know your opinion about this patch
and whether it could be accepted to upstream. Thanks.

Libor


More information about the Gdb-patches mailing list