From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9eR5JRX0Nmp+JhEAWB0awg (envelope-from ) for ; Sat, 20 Jun 2026 16:12:05 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BUMCzf2/; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 880BC1E070; Sat, 20 Jun 2026 16:12:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS autolearn=no 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 6FC631E070 for ; Sat, 20 Jun 2026 16:12:03 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 971DF4BB1C1F for ; Sat, 20 Jun 2026 20:12:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 971DF4BB1C1F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BUMCzf2/ Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 4B19D4BAE7DB for ; Sat, 20 Jun 2026 20:11:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B19D4BAE7DB Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4B19D4BAE7DB Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781986299; cv=none; b=qEHIRJZg4gLhZGNfjKTn4QVzU9IxzWXwipkXMTVFoLBqriupIaWX6s1/LQCubAmoT/UFuywDp1TX5bV3kleFdo4JMXIVGPYJf0EX3hLaBoVhXmp+GEF9w1BECmWe2VqwByQjb/WyQspL8NL3mke7pWyYePAGR9+qgN8dhPQvx/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781986299; c=relaxed/simple; bh=7KMHuhj3ri3EZyv0muWQtQUgoS1FsAb57FUCeppGXXw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=UIXZhv5VAF7AelXo6WJk+Hs8Vvqh6T4A004U4xUEenU9hlic31PcuDsY0j9csPS/W0vbFGv3xJGLH9G+BhdUjj03I9dlmFds8f3NNtvYA5sw9tKkDXzOafv77MQIb8ciiH/0KzT1R3d4BOQpCsO4Y8X0VzNY0fwfF5064lQhroQ= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BUMCzf2/ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B19D4BAE7DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781986299; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ET9PAC6w81JA9HU44SX1Gn0wc0wZxWDpwI7BueSQ8jY=; b=BUMCzf2/RyMfHaA0hmS6pqX0Ll/rCYo3x8YxBvgvHxa6/5oHCpDbmI61keWfdSqdzl39H3 YdTToSWGjWYn19H8jj3DAC7Wi4a1hTsWX5IU135SdGx41KCwP+7OBw6bPVqZQHupA0xLsV 4CYtSGY0a/qO5uUgzlas0Htls93asb0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-184-kU16Kw-fPoew-2UIyr5ExA-1; Sat, 20 Jun 2026 16:11:37 -0400 X-MC-Unique: kU16Kw-fPoew-2UIyr5ExA-1 X-Mimecast-MFC-AGG-ID: kU16Kw-fPoew-2UIyr5ExA_1781986296 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0B60A19560AF; Sat, 20 Jun 2026 20:11:36 +0000 (UTC) Received: from f44-mesa-1 (unknown [10.22.64.33]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E2FCFD6E; Sat, 20 Jun 2026 20:11:34 +0000 (UTC) Date: Sat, 20 Jun 2026 13:11:32 -0700 From: Kevin Buettner To: Ronald Hecht Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3] gdb: z80: Fix endless loop in frame unwinder and validate saved register types Message-ID: <20260620130931.4004215f@f44-mesa-1> In-Reply-To: <20260615070401.8671-1-ronald.hecht@gmx.de> References: <20260614150230.2fd33d6e@f44-mesa-1> <20260615070401.8671-1-ronald.hecht@gmx.de> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: RKh90pyKlrq_ZoMsiqrhN3-Vj_-STFFg5fgrBo8_Kjk_1781986296 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Hi Ronald, This looks great! Thanks for making the changes I requested. On Mon, 15 Jun 2026 09:04:01 +0200 Ronald Hecht wrote: > In z80_frame_unwind_cache, the loop scanning for the frame base pointer > (for (;; ++sp)) could run into an endless loop or scan too far if the > termination condition (sp < this_base) was not met due to corrupted > or unexpected stack layouts. This patch introduces a loop_count to > limit the scan to a maximum of 2 * addr_len iterations. > > Additionally, when iterating through saved registers to adjust their > offsets into concrete addresses, the code now explicitly checks if > the register actually holds an address using is_addr() before calling > addr(). This prevents potential assertions or undefined behavior for > registers that do not contain valid address data. > > gdb/ChangeLog: > > * z80-tdep.c (z80_frame_unwind_cache): Limit stack scanning > to 2 * addr_len iterations to prevent endless loops. Check > is_addr() before adjusting saved register addresses. The ChangeLog entry isn't required, but there's no harm in having it in the commit log. Regardless, don't add it to any ChangeLog files prior to pushing it. Approved-By: Kevin Buettner