From patchwork Tue Mar 21 19:42:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66720 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D69473858C2D for ; Tue, 21 Mar 2023 19:43:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D69473858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679427792; bh=7d+HOi+Wa5o5SE18mR9dWvahNBO36EBgmOxcioVo2ik=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ZWPtdPBvWojaS7/Lmxeb7soY6ZMZw5RVabhf6gtQWBzFwzez4WcEaeja8qTvtNnhC BH5T4VBUTlZo5C0VpuxIkoeQis7QvF4NLsgEsWIi6WrS6r/f4AycYLPVCOghnFxtN7 m1mELG2P5FS/jMMRvf97SJAedpUFcCUU+1xsLjfA= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 69A023858D3C for ; Tue, 21 Mar 2023 19:42:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69A023858D3C Received: by mail-il1-x136.google.com with SMTP id s7so8722686ilv.12 for ; Tue, 21 Mar 2023 12:42:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679427768; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7d+HOi+Wa5o5SE18mR9dWvahNBO36EBgmOxcioVo2ik=; b=RIIX+HIQwc/6GQcejK5HsuE5zTnJAN7Q3xWyEE1ONitq1tEhncAtvSKxyChIKQKWWv YdgzXdUrhlMJtK1FHFT/cTXg3mHWxpZ2Ze32X+6QLaAealcEeh2fHVran+qrwSJ6V3SL giTMGTZhutVFdAScIkbbb7/XB5d9p2oJovWiC+EVGI1xDLPrVU6zeoz+X3TSrME/VkoL eOoyci6WMEVUH7uohTIwFPdPsg03E8dwDCNZxKZb5LNKUi98/udCkxOyrDZRxJXtLZW1 M/y5BAfoGCRggW6sl5SiduSztxttG/pE+pB8kVYTCgHVXSlJ4br4p0omIQRGnr43SkOF XYYw== X-Gm-Message-State: AO0yUKVLNmfIDRX/FZoyzkGk1DDpTpNkShBOXMmy3LutyCJzQN48k41k jJx0andzNDPbfokSl7U6oWggVh/8PP2pjnNWSuPSqA== X-Google-Smtp-Source: AK7set9C/u8DknKK0RLkJWD1QBrmVtWXT8RqGrPFc6dOvuHvTS3LBZn/JLCR3PkIEVXGVSkv61ukTw== X-Received: by 2002:a92:c530:0:b0:315:6e7f:f429 with SMTP id m16-20020a92c530000000b003156e7ff429mr2383167ili.9.1679427768604; Tue, 21 Mar 2023 12:42:48 -0700 (PDT) Received: from localhost.localdomain (71-211-185-113.hlrn.qwest.net. [71.211.185.113]) by smtp.gmail.com with ESMTPSA id n22-20020a056638265600b003bf39936d1esm4236395jat.131.2023.03.21.12.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 12:42:48 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Handle unwinding from SEGV on Windows Date: Tue, 21 Mar 2023 13:42:40 -0600 Message-Id: <20230321194240.1766622-1-tromey@adacore.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" PR win32/30255 points out that a call to a NULL function pointer will leave gdb unable to "bt" on Windows. I tracked this down to the amd64 windows unwinder. If we treat this scenario as if it were a leaf function, unwinding works fine. I'm not completely sure this patch is the best way. I considered having it check for 'pc==0' -- but then I figured this could affect any inaccessible PC, not just the special 0 value. No test case because I can't run dejagnu tests on Windows. I tested this by hand using the test case in the bug. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30255 --- gdb/amd64-windows-tdep.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 07df64bed60..9d69ec282d2 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -1098,13 +1098,14 @@ amd64_windows_frame_cache (frame_info_ptr this_frame, void **this_cache) cache->sp = extract_unsigned_integer (buf, 8, byte_order); cache->pc = pc; + /* If we can't find the unwind info, keep trying as though this is a + leaf function. This situation can happen when PC==0, see + https://sourceware.org/bugzilla/show_bug.cgi?id=30255. */ if (amd64_windows_find_unwind_info (gdbarch, pc, &unwind_info, &cache->image_base, &cache->start_rva, - &cache->end_rva)) - return cache; - - if (unwind_info == 0) + &cache->end_rva) + || unwind_info == 0) { /* Assume a leaf function. */ cache->prev_sp = cache->sp + 8;