From: Kevin Buettner <kevinb@redhat.com>
To: Tom de Vries <tdevries@suse.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] [gdb/testsuite] Extend gdb.base/kill-during-detach.exp
Date: Wed, 10 Jan 2024 12:16:36 -0700 [thread overview]
Message-ID: <20240110121636.359dfbf6@f39-zbm-amd> (raw)
In-Reply-To: <20240109165620.18066-1-tdevries@suse.de>
On Tue, 9 Jan 2024 17:56:20 +0100
Tom de Vries <tdevries@suse.de> wrote:
> I ran into the following FAIL:
> ...
> (gdb) python kill_and_detach()^M
> Traceback (most recent call last):^M
> File "<string>", line 1, in <module>^M
> File "<string>", line 7, in kill_and_detach^M
> gdb.error: Selected thread is running.^M
> Error while executing Python code.^M
> (gdb) FAIL: gdb.base/kill-during-detach.exp: exit_p=true: checkpoint_p=true: \
> python kill_and_detach()
> ...
>
> The FAIL happens as follows:
> - gdb is debugging a process A
> - a checkpoint is created, in other words, fork is called in the inferior,
> after which we have:
> - checkpoint 0 (the fork parent, process A), and
> - checkpoint 1 (the fork child, process B).
> - during checkpoint creation, lseek is called in the inferior (process A) for
> all file descriptors, and it returns != -1 for at least one file descriptor.
> - the process A continues in the background
> - gdb detaches, from process A
> - gdb switches to process B, in other words, it restarts checkpoint 1
> - while restarting checkpoint 1, gdb tries to call lseek in the inferior
> (process B), but this fails because gdb incorrectly thinks that inferior B
> is running.
>
> This happens because linux_nat_switch_fork patches the pid of process B into
> the current inferior and current thread which where originally representing
> process A. So, because process A was running in the background, the
> thread_info fields executing and resumed are set accordingly, but they are not
> correct for process B.
>
> There's a line in fork_load_infrun_state that fixes up the thread_info field
> stop_pc, so fix this by adding similar fixups for the executing and resumed
> fields alongside.
>
> The FAIL did not always reproduce, so extend the test-case to reliably
> trigger this scenario.
Thanks for the detailed explanation!
Makes sense to me...
Approved-By: Kevin Buettner <kevinb@redhat.com>
prev parent reply other threads:[~2024-01-10 19:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-09 16:56 Tom de Vries
2024-01-10 19:16 ` Kevin Buettner [this message]
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=20240110121636.359dfbf6@f39-zbm-amd \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/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