From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3C66C384C00B; Wed, 14 Jul 2021 14:41:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C66C384C00B From: "simark at simark dot ca" To: gdb-prs@sourceware.org Subject: [Bug record/28086] inferior.c:303: internal-error: inferior* find_inferior _pid(process_stratum_target*, int): Assertion `pid != 0' failed. Date: Wed, 14 Jul 2021 14:41:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: record X-Bugzilla-Version: unknown 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 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: Wed, 14 Jul 2021 14:41:48 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28086 --- Comment #4 from Simon Marchi --- I didn't manage to reproduce: # of expected passes 7 At frame 42, we have the new_thread observable being fired, because a new thread is being added. When the new_thread observable, I don't think there= is any guarantee about the global context, value of inferior_ptid and all. btrace_compute_ftrace_bts at frame 32 is the last frame where we know the thread we are working on. It then calls gdb_insn_length which eventually c= alls target_read. So from gdb_insn_length and on, inferior_ptid and the rest of= the global context should be set appropriately. I think that btrace_compute_ftrace_bts should set and restore the current thread (ideall= y, it should pass down the thread, but that's for another day). Here's an untested patch (well, I tested it, the test still passes for me, = but I don't know if it fixes your regression): diff --git a/gdb/btrace.c b/gdb/btrace.c index 5e689c11d4bd..93e7bc438a7e 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1104,6 +1104,11 @@ btrace_compute_ftrace_bts (struct thread_info *tp, size =3D 0; try { + /* gdb_insn_length will need to read memory from TP, which may + not be the current thread on entryt. Make sure it is. */ + scoped_restore_current_thread restore_thread; + switch_to_thread (tp); + size =3D gdb_insn_length (gdbarch, pc); } catch (const gdb_exception_error &error) --=20 You are receiving this mail because: You are on the CC list for the bug.=