From patchwork Wed Nov 15 13:52:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 79945 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 AB1ED3858C29 for ; Wed, 15 Nov 2023 13:52:31 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id B45073858C98 for ; Wed, 15 Nov 2023 13:52:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B45073858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B45073858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700056339; cv=none; b=VszpdaIMWuwQsCUG2CC/OOX9VAUrXDVnF3/tdS+Fk1910si9WPy4sRJxxlk7viEhXjy0ag19xGFtkme9ZiPP0XWIONEixUn/9WXHG7XLe6st8EkqNNPrPYvIIeb23D6hfRBpfdINl89wBFd/GhxFJtPPeIWZQ7BlMMU2yrLL7tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700056339; c=relaxed/simple; bh=l5qymJzm0RxuFmmnwZc/FSr4noAQ2JB73rU+Eg4OrKQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VgZ1iWKceNI8G2lLa7HgA4i7wJaevrcCaykrkgTwuHCX9017P2LkOlga0oRfP5gfzmeHWC7hQWK/uZ6yzMZoVKQZjtM6UdYo7DEl+Yi+0saWzpowiuI9DnveViZ9rWzXDPVIvbG6uUCaRnmL/hV+x1lEcfiWDURAITsIIWXPJis= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7a69a1b51baso20520739f.1 for ; Wed, 15 Nov 2023 05:52:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1700056336; x=1700661136; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iUViqLg9xTq1wkpJoEJX6zytfKSjk1B0SqA/ItpvoXI=; b=OReec0fAMLWGH1ly+i+qu4Xv0vhlPhiNLGUJckC8TnoT0PUDxQ/YbGD38tvINfqVEx 4LMzIBVM107+bjYZrt3NgqTRJyKAwzsCl/krD6hqF/Yvc9bfnb9iDbagDZcPG627ItAP 5u69NxXhxUbd+HHa1gouPmxhhmfPrNVvGWnEQDfF4Hga1df/v92HBe34jNQEXKUqcsfw nGRFKE3WtfnBYF6ZyrFqbDX0JftXoxvZuyHScZ0V7vP24yj/CyUmyAvXYyAJgiNomu5X wgGUabgPlRWrubuEM3Sd8qYhhU8/FAzrvyAeSQMkzcXCW9iVpDrL+qTNqPEMSgTT/may T0MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700056336; x=1700661136; 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=iUViqLg9xTq1wkpJoEJX6zytfKSjk1B0SqA/ItpvoXI=; b=wFlPDYRHKBR83Ye3pyuweQz1DlxFgmZGYKhw/1TBNmpAUUxATofeFtHw+4kTpFGCTW RaTiurJs3jOY37S6cLH8b2HmqHSlWdQRunWEHTCbDzuIuPLLg9QN0pOBkoX1qoMnP8Q2 i1M8lzw1QRRDSt1n15TjdoyAh7w8FQO/xbJ0upfQ0Pxc09U6nMfSFdinuMsGcUh8L/6/ Nl98v3DM6HfdXFjh+dK6qg+ANnuNJIh6NJ0T8kgLQb9gAMj5LBYQW3iV9LAk2WSsIXV7 1pgD7TACwHDu6tXjKqonqZnokIHx+pqF2aPU5pubIjFZG5sLJ5rcZPVPekxAJUCWvOzv cRcQ== X-Gm-Message-State: AOJu0Yw6kgmsKPlieIP5aQdt5tCh2NjxkvjJLCNZwJqi6GXy6J2IWW2J rd9bPXd7buowOJwn2jwjYTpbXrZDhf9BS5hDcSzRMw== X-Google-Smtp-Source: AGHT+IE1jZNMU4y54uWKUsREu5VmbwzyG/4F9mO9rtXVr/2miD5X18LILfvMNoYxK1EPWK+herRPCw== X-Received: by 2002:a6b:c846:0:b0:7a6:7b18:dbf3 with SMTP id y67-20020a6bc846000000b007a67b18dbf3mr5590190iof.7.1700056336149; Wed, 15 Nov 2023 05:52:16 -0800 (PST) Received: from localhost.localdomain (97-122-77-73.hlrn.qwest.net. [97.122.77.73]) by smtp.gmail.com with ESMTPSA id br7-20020a05663846c700b0042ad887f705sm1013400jab.143.2023.11.15.05.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 05:52:15 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Check gdb_python_module in gdbpy_handle_missing_debuginfo Date: Wed, 15 Nov 2023 06:52:04 -0700 Message-ID: <20231115135204.3747216-1-tromey@adacore.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 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, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org If you run gdb in the build tree without --data-directory, on a program that does not have debug info, it will crash, because gdbpy_handle_missing_debuginfo unconditionally uses gdb_python_module. Other code in gdb using gdb_python_module checks it first. I'm not really sure why gdb_python_initialized does not cover this case (maybe so that python can be partially initialized and still somewhat work?), but it seemes harmless to do the same thing here. --- gdb/python/python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/python/python.c b/gdb/python/python.c index 4523e30ed24..7e48165db21 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1703,7 +1703,7 @@ gdbpy_handle_missing_debuginfo (const struct extension_language_defn *extlang, struct objfile *objfile) { /* Early exit if Python is not initialised. */ - if (!gdb_python_initialized) + if (!gdb_python_initialized || gdb_python_module == nullptr) return {}; struct gdbarch *gdbarch = objfile->arch ();