From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 086AE3990814; Fri, 7 May 2021 14:16:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 086AE3990814 From: "andrew.burgess at embecosm dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/27830] New: Attempt to resume already running thread Date: Fri, 07 May 2021 14:16:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: andrew.burgess at embecosm dot com 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2021 14:16:55 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27830 Bug ID: 27830 Summary: Attempt to resume already running thread Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: andrew.burgess at embecosm dot com Target Milestone: --- Created attachment 13423 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D13423&action=3Ded= it reproducer When using 'target remote', 'set non-stop on' and 'set displaced-stepping o= ff', if we step over an instruction that creates a new thread then GDB ends up trying to resume a thread that is already running. To reproduce, download the attached tar file then: $ tar -xf thr-resume-issue.tar.xz $ cd thr-resume-issue $ make .....snip.... [New Thread 3878916.3878917] cmd.gdb:12: Error in sourced command file: PC register is not available **** FAILED **** This test case is only going to work on an x86-64/Linux setup. Notice the "PC register is not available" error. This is caused by GDB try= ing to read the $pc from the new running thread. In more detail what happens is that GDB stops at the syscall instruction th= at will spawn a new thread. At this point the inferior is single threaded. Next we 'stepi', as displaced stepping is off we do inplace stepping. When the step is completed we end up in finish_step_over (infrun.c), this t= hen calls restart_threads. In restart_threads we call update_thread_list and spot the new thread. The thread is created with executing =3D=3D true and state =3D=3D THREAD_RUNNIN= G, but, resumed =3D=3D false. Back in restart_threads we then loop over all threads and try to put the th= read "back to what they were trying to do back when we paused them for an in-line step-over." For our new thread we try to resume the thread (even though it's already running), which requires a read of $pc, which causes the error we see. --=20 You are receiving this mail because: You are on the CC list for the bug.=