From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 1HLcEd8Ls2nUUyYAWB0awg (envelope-from ) for ; Thu, 12 Mar 2026 14:54:23 -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=Rfr+2ub9; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2E06A1E089; Thu, 12 Mar 2026 14:54:23 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 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_DNSWL_MED,RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED 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 6972A1E089 for ; Thu, 12 Mar 2026 14:54:22 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id C15294BC7EFF for ; Thu, 12 Mar 2026 18:54:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C15294BC7EFF 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=Rfr+2ub9 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 3174D4BA23E8 for ; Thu, 12 Mar 2026 18:53:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3174D4BA23E8 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 3174D4BA23E8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773341635; cv=none; b=qdpA6iT56OD5M4LKS31giogVJsIE2L5K9Q89vTW+xDwOcHCHUI2zEO1ysPDpHnSiLT9iyA90xogL3/zOJ39gYmsyBRcekN9Jh60RxqD7CwgmhAIGFnJIM07GQ1ltCxBcI5Y4A+M9Sv38OajKJtDsW4snkXSMnKO08+VHUnBz8Rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773341635; c=relaxed/simple; bh=1GGRWIm/gEFbpsVKjE5/Cbmm3Rl2oi9GWwlgOxYzMxY=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=DbujZuaebu8ZGIsfIXLw1eQu9CeLosJH40Vkp03HUX5BFBBeuTsTEODk9TSd8cxPpxLGEuQfKKTaob1H3xnVIiLCQRbi1pt6OMtvCWKL1MZrYRQ+z7AopSnDQGhI3shO3sTgs8Lkw1xIW2k/p/4wVdTC9oWel95fbs4im0Vtclk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3174D4BA23E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773341634; 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=ixb16JiKuLFkwy+g+vnOkQqY3QBbcuSrt5mvGBZOTBU=; b=Rfr+2ub9V/O79HQVvaJsUAUUh0iY4YlTEq2yRO/SD1hXUBwYOfhBKHfYYk+CWLcmVSU1zR NaBEpqX0gq9yCVhuGl9UU2wQRMT6YGz4wSWHW2+JLslJ6sFRzrKw6hIPLOaBmN1oswiGxE d3EB7VzuSKEQCa7G3d+4mN2CfEKOUn0= 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-526-CJG7u8ZgO-iUNrjrc9pgKA-1; Thu, 12 Mar 2026 14:53:53 -0400 X-MC-Unique: CJG7u8ZgO-iUNrjrc9pgKA-1 X-Mimecast-MFC-AGG-ID: CJG7u8ZgO-iUNrjrc9pgKA_1773341633 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 801C31953941 for ; Thu, 12 Mar 2026 18:53:52 +0000 (UTC) Received: from f42-zbm-amd (unknown [10.22.88.47]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C1976180035F; Thu, 12 Mar 2026 18:53:51 +0000 (UTC) Date: Thu, 12 Mar 2026 11:53:49 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: Re: [PATCH] gdb: fix edge case assertion from get_selected_frame Message-ID: <20260312115349.5ac6368e@f42-zbm-amd> In-Reply-To: <8dd362133f03ae70dc917b4ae7570fa93bf9b584.1772892600.git.aburgess@redhat.com> References: <8dd362133f03ae70dc917b4ae7570fa93bf9b584.1772892600.git.aburgess@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: bFRD_L_M2zgRFndPJ99XPFwHh6eCZ8s06ZsXxeSlvqw_1773341633 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 Andrew, On Sat, 7 Mar 2026 14:10:19 +0000 Andrew Burgess wrote: > diff --git a/gdb/frame.c b/gdb/frame.c > index 8cb1d0a5c42..8644e029e61 100644 > --- a/gdb/frame.c > +++ b/gdb/frame.c > @@ -1874,21 +1874,30 @@ lookup_selected_frame (struct frame_id > a_frame_id, int frame_level) return; > } > > - /* Nothing else to do, the frame layout really changed. Select the > - innermost stack frame. */ > - select_frame (get_current_frame ()); > + /* We are unable to restore the required frame, so instead we'll > + select the current (innermost) frame. Do this before actually > + setting the frame as print_stack_frame can make calls into > + extension language hooks, which could invalidate the frame cache, > + which will clear the selected frame. I found this comment puzzling. I initially interpreted "Do this before..." as refering to the processs of selecting a frame as mentioned in the previous sentence. But I now think that "this" is actually referring to the code below the comment. Perhaps this construction is less confusing?... /* We are unable to restore the required frame, so instead we'll select the current (innermost) frame. We print the warning first as print_stack_frame can make calls into extension language hooks, which could invalidate the frame cache and clear the selected frame. ... > > - /* Warn the user. */ > + We only warn the user if we're trying to select something other > + than frame #0 though, as the fallback is to just select the > + current frame #0, even if it's different to the frame #0 we tried > + to find (e.g. the frame-id changed). */ > if (frame_level > 0 && !current_uiout->is_mi_like_p ()) > { > - warning (_("Couldn't restore frame #%d in " > - "current thread. Bottom (innermost) frame selected:"), > + warning (_("Couldn't restore frame #%d in current thread. " > + "Innermost frame selected:"), > frame_level); > /* For MI, we should probably have a notification about current > frame change. But this error is not very likely, so don't > bother for now. */ > - print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); > + print_stack_frame (get_current_frame (), 1, SRC_AND_LOC, 1); > } > + > + /* We couldn't find the frame we were looking for, so just restore > + the innermost frame instead. */ > + select_frame (get_current_frame ()); > } You might also consider adding a comment regarding this observation from your commit message: ... There is just one theoretical bug that I haven't tried to fix; if the pretty printer changed the machine state then it is possible that the current frame that's selected is not the current frame that was printed. This could be confusing, but not I think fatal. Trying to fix this felt like taking things too far, so I've left this for now. Perhaps something like this?: /* Note: get_current_frame() is called twice - once for printing and again for selection. In theory, an extension language hook could change machine state between these calls, making the printed and selected frames different. This could be confusing but is likely not fatal. */ Aside from those documentation nits, the change and the test look fine to me. Approved-by: Kevin Buettner