This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/8] Fix follow-fork latent bug
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 12 Apr 2017 00:51:07 +0100
- Subject: [PATCH 2/8] Fix follow-fork latent bug
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 238577F7A5
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 238577F7A5
- References: <1491954673-29172-1-git-send-email-palves@redhat.com>
A later patch in the series adds an assertion to switch_to_thread that
the resulting inferior_ptid always matches the "current_inferior()"
inferior. This exposed a latent bug in the follow-fork code, where
we're building the fork child inferior. We're switching
inferior_ptid, but not the current inferior object...
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* infrun.c (follow_fork_inferior): Also switch the current
inferior.
---
gdb/infrun.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index b5eb4ab..c7298a3 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -498,11 +498,11 @@ holding the child stopped. Try \"set detach-on-fork\" or \
child_inf->gdbarch = parent_inf->gdbarch;
copy_inferior_target_desc_info (child_inf, parent_inf);
- old_chain = save_inferior_ptid ();
- save_current_program_space ();
+ old_chain = save_current_space_and_thread ();
inferior_ptid = child_ptid;
add_thread (inferior_ptid);
+ set_current_inferior (child_inf);
child_inf->symfile_flags = SYMFILE_NO_READ;
/* If this is a vfork child, then the address-space is
@@ -631,6 +631,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \
inferior_ptid = child_ptid;
add_thread (inferior_ptid);
+ set_current_inferior (child_inf);
/* If this is a vfork child, then the address-space is shared
with the parent. If we detached from the parent, then we can
--
2.5.5