From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oWocH7lLgmo5BysAWB0awg (envelope-from ) for ; Sun, 16 Aug 2026 19:46:01 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=embedded-brains.de header.i=@embedded-brains.de header.a=rsa-sha256 header.s=34EE5404-8E36-11F0-B577-2ECCAB4968F5 header.b=g5bijAh1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 79C911E09B; Sun, 16 Aug 2026 19:46:01 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7A0101E09B for ; Sun, 16 Aug 2026 19:46:00 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 94EA74BA2E38 for ; Sun, 16 Aug 2026 23:45:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94EA74BA2E38 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=embedded-brains.de header.i=@embedded-brains.de header.a=rsa-sha256 header.s=34EE5404-8E36-11F0-B577-2ECCAB4968F5 header.b=g5bijAh1 Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id AB0014BA2E24 for ; Sun, 16 Aug 2026 23:44:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB0014BA2E24 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AB0014BA2E24 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=85.10.215.148 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786923848; cv=none; b=xvC9gZqsdzZ33sSxD2B3urQpS5QZOXe58YuJiAcNiM4bYiywX8/8bGSg5WzLBRpMkD28Cqi2eZgPyg7OwuOwZN4rFnfcBu13Lv39cQGQRUFgv1JMUZwS/+z7bOWOMIlAqJeycxF4QCKPxrbrd3qN5yyIufzCCVCi7Jh3y3jaKwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786923848; c=relaxed/simple; bh=GHkG5qwLq274AXrIwgfSQgHcJEs+jjs8mIg5vuBxc3Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qNzWeFTuFU9CmpgV6Rpb5vezdn0/ifEbqodbb8EPSdtULcNSAnqxamdpYvduZ/F7ysA0RVpxQT7Eoz+vHfkDrGiT4l+SwC/3nxfmyRAniN0UtGbceJTjWBOUEwjXlywYtIQG35rQNVkSJR0ZrLUtcoxzE1ly7ld10tuM1QFzspQ= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=embedded-brains.de header.i=@embedded-brains.de header.a=rsa-sha256 header.s=34EE5404-8E36-11F0-B577-2ECCAB4968F5 header.b=g5bijAh1 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB0014BA2E24 Received: from sslproxy06.your-server.de ([78.46.172.3]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1wvkWL-0009tl-1m for gdb-patches@sourceware.org; Mon, 17 Aug 2026 01:44:06 +0200 Received: from localhost ([127.0.0.1]) by sslproxy06.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wvkWL-000PC5-1j for gdb-patches@sourceware.org; Mon, 17 Aug 2026 01:44:05 +0200 Received: from localhost (localhost.eb.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 70B624800A2 for ; Mon, 17 Aug 2026 01:44:05 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavis, port 10032) with ESMTP id xzZtYDbHoeDu for ; Mon, 17 Aug 2026 01:44:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 22D3C48007A for ; Mon, 17 Aug 2026 01:44:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.embedded-brains.de 22D3C48007A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embedded-brains.de; s=34EE5404-8E36-11F0-B577-2ECCAB4968F5; t=1786923845; bh=Q0pRDxQkFH6T4sFb86nDZ54Y4INgmUQi2qG2zSfPc3k=; h=From:To:Date:Message-ID:MIME-Version; b=g5bijAh1HiJcLESG8cJB63mFfNBlUegfWyO/Bm6NmWvXyEygz+DCS2iXkUu7paxeZ 8jBH64oGE77x3qXj26siWlkcbfS0Tgv4PFxcl6MCOz4+mrDg0c5ABr9ojnRt9JN2iZ JuxrsFVB0CGhs2I4ltf6gXGsUMAooeSbU7b/gWAYLrdFwjRCZrEpNcigsAfAPlmWsv qBupfY0CecUGZMCwp1dXIqVytcsv+CcnzIiDJ6GW5o8cNN1TTdVEmG3k7XJiQ09GYQ H2nXXba6a3tuWYssIgNQHh5cJ/aAumnGa3a3xEeyvfpMsHA89wkB4AjQsqWpeCOXyZ DrBXYgkNjTY2Q== X-Virus-Scanned: amavis at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavis, port 10026) with ESMTP id KN9eCvJWkhAc for ; Mon, 17 Aug 2026 01:44:05 +0200 (CEST) Received: from zimbra.eb.localhost (unknown [10.10.171.14]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 798024800A2 for ; Mon, 17 Aug 2026 01:44:04 +0200 (CEST) From: Sebastian Huber To: gdb-patches@sourceware.org Subject: [PATCH 1/4] sim: Allow an overdue event to be descheduled Date: Mon, 17 Aug 2026 01:43:53 +0200 Message-ID: <20260816234357.278358-2-sebastian.huber@embedded-brains.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260816234357.278358-1-sebastian.huber@embedded-brains.de> References: <20260816234357.278358-1-sebastian.huber@embedded-brains.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-DKIM-Status: pass [(embedded-brains.de) - 78.46.172.3] X-Virus-Scanned: Clear (ClamAV 1.4.3/28094/Sun Aug 16 08:26:19 2026) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org sim_events_deschedule() asserted that a non-empty event queue implies a non-negative time from event. That is not an invariant. sim_events_slip() decrements the time from event unconditionally, so the time can pass an event which is still queued. update_time_from_event() then computes a negative time from event for the head of the queue, which is overdue rather than pending. The next tick raises the pending work flag and sim_events_process() consumes it, so nothing is lost. An event handler which deschedules another overdue event triggers the assertion. The MIPS jmr3904 board reaches this with two timers running: they queue events for the same time, a branch delay slot slips the time past both, and the handler of the first deschedules the second. Assert only the direction which holds: an empty queue gives a negative time from event. Signed-off-by: Sebastian Huber --- sim/common/sim-events.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c index f87f133efc3..e908c40f764 100644 --- a/sim/common/sim-events.c +++ b/sim/common/sim-events.c @@ -852,7 +852,11 @@ sim_events_deschedule (SIM_DESC sd, (dead->trace !=3D NULL) ? dead->trace : "")); sim_events_free (sd, dead); update_time_from_event (sd); - SIM_ASSERT ((events->time_from_event >=3D 0) =3D=3D (events->queu= e !=3D NULL)); + /* sim_events_slip() advances the time past an event + which is still queued. The head of the queue is then + overdue rather than pending. */ + SIM_ASSERT (events->queue !=3D NULL + || events->time_from_event < 0); return; } } --=20 2.51.0