From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1E9113858D28; Fri, 11 Nov 2022 01:16:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E9113858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668129368; bh=w7ifP0vKoVBhOIFN9vd7HtXdJsLKgJCdU3etju7NNo8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hwwTmZaYNVPHfYbMFURMtkTGN3uLHzNxiYcokf8mRM7GGVvJ0vRkTo8pLEBIayCMj XZjeU7G7W/OZQr+6hnsMu9pvsuEkTbhxSDfWLqCdCg3FWCGZHcE0T/L+LW6vt6W54A aop+d8RUcsVOSoN70ddVYkIKhwQw6qmAX6kLdCiA= From: "simark at simark dot ca" To: gdb-prs@sourceware.org Subject: [Bug gdb/29762] FAIL: gdb.threads/access-mem-running-thread-exit.exp: non-stop: access mem (print global_var after writing again, inf=2, iter=1) Date: Fri, 11 Nov 2022 01:16:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: simark at simark dot ca X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29762 --- Comment #1 from Simon Marchi --- > I don't really know what kind of racy problem it could be in GDB. It sou= nds > like a "write memory on one core, get migrated to another CPU, then read = the > old value on another core" kind of problem. Of course it's absolutely not that. It turns out that with this change in the test, it reproduces pretty much e= very time: diff --git a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp index 7932c0a82e6..54080e5e5bc 100644 --- a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp +++ b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp @@ -172,10 +172,13 @@ proc test { non_stop } { my_gdb_test "print global_var =3D 555" " =3D 555" \ "write to global_var" + sleep 1 my_gdb_test "print global_var" " =3D 555" \ "print global_var after writing" + sleep 1 my_gdb_test "print global_var =3D 333" " =3D 333" \ "write to global_var again" + sleep 1 my_gdb_test "print global_var" " =3D 333" \ "print global_var after writing again" } By putting some printfs in gdbserver (and hacking the testsuite so it would connect to the gdbserver I started manually, so I could see its stdout), I found that we would end up writing or reading from the wrong inferior.=20 Sometimes, it happens that prior to a memory access operation (use to imple= ment those prints), GDB tries to set the remote general thread, but it fails bec= ause that thread has just exited (and GDB doesn't know about it). The Hg packet fails, but we don't check the response: https://gitlab.com/gnutools/binutils-gdb/-/blob/cde010e1a866e67b7e895cbcb95= dedd3de0a1e56/gdb/remote.c#L2914 So GDB proceeds with the memory operation with the previous remote general thread still set, which belongs to the other inferior. --=20 You are receiving this mail because: You are on the CC list for the bug.=