From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0FE0B385841F; Mon, 16 Oct 2023 10:57:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FE0B385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1697453837; bh=HcjMAwYKZE4IodSyYXdc1laHtVNrCKfVnlS4qNNVNSo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kWkvzNHk4fUU7Ep+IzlHc462JXsocUdaFrzS00GDNkhHpnJoANJmBK02bR409p53M XFKsYkmIMLi6gUp31yUHm3XhwkTErBSYTuqubEpvXEsyqC5dwZGy1LgH4mmAPESNxh GuQobdLloDYxrH08YedW9R1XGGRCJtRmoanGWXV0= From: "cvs-commit at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/30872] Assertion `buffer.copy_insn_closure.get () != nullptr' failed Date: Mon, 16 Oct 2023 10:57:15 +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: 13.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED 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=3D30872 --- Comment #13 from cvs-commit at gcc dot gnu.org --- The master branch has been updated by Luis Machado : https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5d4a870e05ac= 45e3f5a301c672a4079995b5db7a commit 5d4a870e05ac45e3f5a301c672a4079995b5db7a Author: Luis Machado Date: Thu Sep 28 11:08:29 2023 +0100 Only allow closure lookup by address if there are threads displaced-stepping Since commit 1e5ccb9c5ff4fd8ade4a8694676f99f4abf2d679, we have an asser= tion in displaced_step_buffers::copy_insn_closure_by_addr that makes sure a clo= sure is available whenever we have a match between the provided address argu= ment and the buffer address. That is fine, but the report in PR30872 shows this assertion triggering when it really shouldn't. After some investigation, here's what I found out. The 32-bit Arm architecture is the only one that calls gdbarch_displaced_step_copy_insn_closure_by_addr directly, and that's because 32-bit Arm needs to figure out the thumb state of the original instruct= ion that we displaced-stepped through the displaced-step buffer. Before the assertion was put in place by commit 1e5ccb9c5ff4fd8ade4a8694676f99f4abf2d679, there was the possibility of getting nullptr back, which meant we were not doing a displaced-stepping operation. Now, with the assertion in place, this is running into issues. It looks like displaced_step_buffers::copy_insn_closure_by_addr is being used to return a couple different answers depending on the state we're in: 1 - If we are actively displaced-stepping, then copy_insn_closure_by_ad= dr is supposed to return a valid closure for us, so we can determine the thumb mode. 2 - If we are not actively displaced-stepping, then copy_insn_closure_by_addr should return nullptr to signal that there isn't any displaced-step buf= fers in use, because we don't have a valid closure (but we should always have this). Since the displaced-step buffers are always allocated, but not always u= sed, that means the buffers will always contain data. In particular, the buf= fer addr field cannot be used to determine if the buffer is active or not. For instance, we cannot set the buffer addr field to 0x0, as that can b= e a valid PC in some cases. My understanding is that the current_thread field should be a good candidate to signal that a particular displaced-step buffer is active or not. If = it is nullptr, we have no threads using that buffer to displaced-step.=20 Otherwise, it is an active buffer in use by a particular thread. The following fix modifies the displaced_step_buffers::copy_insn_closure_by_addr function so we only attempt to return a closure if the buffer has an assigned current_thread and if the buffer address matches the address argument. Alternatively, I think we could use a function to answer the question of whether we're actively displaced-stepping (so we have an active buffer)= or not. I've also added a testcase that exercises the problem. It should reprod= uce reliably on Arm, as that is the only architecture that faces this probl= em at the moment. Regression-tested on Ubuntu 20.04. OK? Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30872 Approved-By: Simon Marchi --=20 You are receiving this mail because: You are on the CC list for the bug.=