public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/31203] [gdb] FAIL: gdb.base/kill-during-detach.exp: exit_p=true: checkpoint_p=true: python kill_and_detach()
Date: Thu, 11 Jan 2024 09:12:15 +0000	[thread overview]
Message-ID: <bug-31203-4717-Igy0qmSN1u@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31203-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31203

--- Comment #13 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

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

commit 4ece39c56cfdd5647d4061f3c084b9de6f9e443c
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Jan 11 10:12:48 2024 +0100

    [gdb/testsuite] Extend gdb.base/kill-during-detach.exp

    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.

    Tested on x86_64-linux.

    Approved-By: Kevin Buettner <kevinb@redhat.com>

    PR gdb/31203
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31203

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-01-11  9:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-01 20:04 [Bug gdb/31203] New: " vries at gcc dot gnu.org
2024-01-01 20:04 ` [Bug gdb/31203] " vries at gcc dot gnu.org
2024-01-02  8:01 ` vries at gcc dot gnu.org
2024-01-02  8:36 ` vries at gcc dot gnu.org
2024-01-03  8:47 ` vries at gcc dot gnu.org
2024-01-03 10:31 ` vries at gcc dot gnu.org
2024-01-03 10:58 ` vries at gcc dot gnu.org
2024-01-04  4:37 ` kevinb at redhat dot com
2024-01-04 11:20 ` vries at gcc dot gnu.org
2024-01-04 11:21 ` vries at gcc dot gnu.org
2024-01-08 16:29 ` vries at gcc dot gnu.org
2024-01-08 19:05 ` kevinb at redhat dot com
2024-01-09 16:57 ` vries at gcc dot gnu.org
2024-01-11  9:12 ` cvs-commit at gcc dot gnu.org [this message]
2024-01-11  9:13 ` vries at gcc dot gnu.org
2024-01-11  9:15 ` vries at gcc dot gnu.org

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=bug-31203-4717-Igy0qmSN1u@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).