From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id tipyMDd1vWlTlDEAWB0awg (envelope-from ) for ; Fri, 20 Mar 2026 12:26:31 -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=XoLwb1/E; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B6A921E08C; Fri, 20 Mar 2026 12:26:31 -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_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 0150B1E08C for ; Fri, 20 Mar 2026 12:26:30 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 6E6114C3189B for ; Fri, 20 Mar 2026 16:26:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E6114C3189B 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=XoLwb1/E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 8AF424C31807 for ; Fri, 20 Mar 2026 16:26:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8AF424C31807 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 8AF424C31807 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774023963; cv=none; b=W6LxlvkQpenW//o/63PvhZqWoV2Q/DbquGyvjp5On5KBj83v4yu73Ym91pnCvzQkH6OiVJolUv0HMwRVkRO/tWKxO27Ya8E6IYku1AiWTX4Af/LXp58Xyvbpxib18nBjS6jZuK/YXPPASyQ25nfOAVDrbkh/+t670Jdn8ejKU5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774023963; c=relaxed/simple; bh=lJpYyjGytIL/gthmLkGwH8qqgDW3uUOoF3QpfIE7jPc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hRxeVrmNqueYCfQzoK20G7rMgfKFbeIjYGCqqBncBGESj6a8C+DRTyp0o6QHFvehQYXd1OaO9hmgYKSEAzh6jKh/zcGCsh0QiysLvWqGlFsEC0lc3+M0zMmptyNyt+vYLCipih59jnKKEz2Y6xzffbxAjGGfkrrojjJKj2av2II= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AF424C31807 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774023963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tEW2hb2bDqYgIReT302KXvuYZzQK/mUao1wAK8JQwio=; b=XoLwb1/E6+kLZV/N4YDettp/Am6xzyV5Q6J9EmSVC2AR75HptObz7ClT57JXx2JoVBL9Tb CG/SR4ahBFbtv3iHEXvpqdvR4GDTcnh7+GsU68+Ew31YIxviFuT6Dp3uQ79LIhqfyr97z0 NbRFSP3e6y1pa0bsVrsBWGtn6fPxKtQ= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-qhfa9KPzO7eb5UEx2l4O2A-1; Fri, 20 Mar 2026 12:26:01 -0400 X-MC-Unique: qhfa9KPzO7eb5UEx2l4O2A-1 X-Mimecast-MFC-AGG-ID: qhfa9KPzO7eb5UEx2l4O2A_1774023960 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-485c45885e6so31453385e9.0 for ; Fri, 20 Mar 2026 09:26:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774023960; x=1774628760; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tEW2hb2bDqYgIReT302KXvuYZzQK/mUao1wAK8JQwio=; b=HLtyKG5RB5EomjbgN+2hf6SFWow8/JLo55fYuTdKlFn/G7xUGf20BvkjYUooYy4LB8 LG9rFOt3NtMkdYHYHnFf47Ee/OQED2xaT618lN7T+AS2REDuQzxj0NnBx35uy3O1GYAD Dw9WuCB8Qe5uDHhwG4ZWxrFYyWXyQLyvdrTDH6XjsqoPdfxJGiY4PRvuiQfKCp22beNW VxOOYUVUWa1XLW/VlnJgBz5Ok+hVd/zCpIOFl0DtNSUQTuvz0Zos5kyhv/4i7m/ZJcfz +pNCf53g6KSamsQKY0+uqRLZrYIVSfpTyoH9xQi3qeArSO+ptPGfwyBEPkBoveABAzgx h7Vg== X-Forwarded-Encrypted: i=1; AJvYcCVFQgD3bEyzkI3e4i+VltGMIJVcHtFsA2trDdOwckc3SQ1yKELQIJZHMXJlO+8RtiCYriHSzW3wPi6hsA==@sourceware.org X-Gm-Message-State: AOJu0YxoLwmAK2228VOzwxHy9ddtc5GYfw9wnnA/30AZVSvwl6Og3xbA cJ4JOsUHiZChs8/Y00c+9uywaSaprT9fsVrN4fXAjhazre0dvX/OAMxEjv4nEYx0EZqb90MUVn9 s0XSbjzeUh6hpAjyHeKzMt6XQDqWqBL3g7Uqks/AdjDMl7AZfuk9F2Ea4cS0nmj2loIR7fk8= X-Gm-Gg: ATEYQzy1uEvVTBpP5eHkPLKDiofl51+tTZU0UEPcK5N7U9+69cHATH0Kv2N2v4u6C9C FfYPg7zfFEDcrN3shyt5MNsE47laM2doDBgAKjxQeV01K3W/1Lz/ddhTUc/1qsJwwXb9fb8zbdt tDp/5/Ex1Jalz+oQFqhWrqQQZn0XyzTFfU2PBtIbmjde9CBn+MVvMPZ9OXCl0vAbEa0IBnP2hlg AMZy4fXomVGNwgGykyEanPy7SssZDZxor1eUJMifltoJzMaUYFXcAmDpyb7ftz/5D1/gX+t7K6l PRoKrAwoX19bT8i1qh4ZOBcA9IWfOXehbCYDUN/lRZmKTPO39eUMJa3CKMwAgspDOfaHL76AHpR FJcanHFccqPyZaZ3A X-Received: by 2002:a05:600c:3112:b0:485:3f72:323f with SMTP id 5b1f17b1804b1-486fedb8c6emr57625345e9.11.1774023959805; Fri, 20 Mar 2026 09:25:59 -0700 (PDT) X-Received: by 2002:a05:600c:3112:b0:485:3f72:323f with SMTP id 5b1f17b1804b1-486fedb8c6emr57625075e9.11.1774023959277; Fri, 20 Mar 2026 09:25:59 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48700658441sm80783055e9.4.2026.03.20.09.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 09:25:57 -0700 (PDT) From: Andrew Burgess To: Kevin Buettner , gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: fix edge case assertion from get_selected_frame In-Reply-To: <20260312115349.5ac6368e@f42-zbm-amd> References: <8dd362133f03ae70dc917b4ae7570fa93bf9b584.1772892600.git.aburgess@redhat.com> <20260312115349.5ac6368e@f42-zbm-amd> Date: Fri, 20 Mar 2026 16:25:55 +0000 Message-ID: <87v7eq4gdo.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sWngy9f4xtYgZiCslY0fpo0GKPC8ybj-unc1G2hXQPk_1774023960 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Kevin Buettner writes: > 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 I improved these comments as you suggested, and pushed this patch. Thanks, Andrew