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/19675] GDB doesn't set PC correctly with displaced stepping over clone syscall
Date: Thu, 05 Aug 2021 09:54:20 +0000	[thread overview]
Message-ID: <bug-19675-4717-4D0z1ocWFi@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-19675-4717@http.sourceware.org/bugzilla/>

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

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Burgess <aburgess@sourceware.org>:

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

commit 99ba4b64d3636533f3659a9c7d3e8504ca93c770
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Tue Jun 8 12:49:04 2021 +0100

    gdb/testsuite: update test gdb.base/step-over-syscall.exp

    I was looking at PR gdb/19675 and the related test
    gdb.base/step-over-syscall.exp.  This test includes a call to kfail
    when we are testing a displaced step over a clone syscall.

    While looking at the test I removed the call to kfail and ran the
    test, and was surprised that the test passed.

    I ran the test a few times and it does sometimes fail, but mostly it
    passed fine.

    PR gdb/19675 describes how, when we displaced step over a clone, the
    new thread is created with a $pc in the displaced step buffer.  GDB
    then fails to "fix" this $pc (for the new thread), and the thread will
    be set running with its current $pc value.  This means that the new
    thread will just start executing from whatever happens to be after the
    displaced stepping buffer.

    In the original PR gdb/19675 bug report Yao Qi was seeing the new
    thread cause a segfault, the problem is, what actually happens is
    totally undefined.

    On my machine, I'm seeing the new thread reenter main, it then starts
    trying to run the test again (in the new thread).  This just happens
    to be safe enough (in this simple test) that most of the time the
    inferior doesn't crash.

    In this commit I try to make the test slightly more likely to fail by
    doing a couple of things.

    First, I added a static variable to main, this is set true when the
    first thread enters main, if a second thread ever enters main then I
    force an abort.

    Second, when the test is finishing I want to ensure that the new
    threads have had a chance to do "something bad" if they are going to.
    So I added a global counter, as each thread starts successfully it
    decrements the counter.  The main thread does not proceed to the final
    marker function (where GDB has placed a breakpoint) until all threads
    have started successfully.  This means that if the newly created
    thread doesn't successfully enter clone_fn then the counter will never
    reach zero and the test will timeout.

    With these two changes my hope is that the test should fail more
    reliably, and so, I have also changed the test to call setup_kfail
    before the specific steps that we expect to misbehave instead of just
    calling kfail and skipping parts of the test completely.  The benefit
    of this is that if/when we fix GDB this test will start to KPASS and
    we'll know to update this test to remove the setup_kfail call.

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

       reply	other threads:[~2021-08-05  9:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-19675-4717@http.sourceware.org/bugzilla/>
2021-08-05  9:54 ` cvs-commit at gcc dot gnu.org [this message]
2021-10-20 15:32 ` vries at gcc dot gnu.org
2022-06-21 11:25 ` pedro at palves dot net
2023-11-13 14:25 ` cvs-commit at gcc dot gnu.org
2023-11-13 14:25 ` cvs-commit at gcc dot gnu.org
2023-11-13 14:25 ` cvs-commit at gcc dot gnu.org
2023-11-13 14:25 ` cvs-commit at gcc dot gnu.org
2023-11-13 14:25 ` cvs-commit at gcc dot gnu.org
2023-11-13 14:26 ` cvs-commit at gcc dot gnu.org
2023-11-13 15:01 ` pedro at palves dot net

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-19675-4717-4D0z1ocWFi@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).