From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9/LaM3QYmWmZgQMAWB0awg (envelope-from ) for ; Fri, 20 Feb 2026 21:29:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1771640948; bh=ihmKSAgp0s08Rg2pWkLUZV0QAptSRCItPUVRcrSsf/Q=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qUbVZN3Teh9ftJxD5GLSrw5Spc82iDwYnnweJSZ2OYb782M5C+SQmqnVF7oih9qjw CwlL87KpQrMuN/VOtvyOzqenqcVj0JRkrM5nJ1QD2ow3kQ0oynzlBWYBIMonnuvSwR blgT6nyG3whj0QxRDdIiMlwiJT7Iil8tNfEybZ98= Received: by simark.ca (Postfix, from userid 112) id BDDD61E08D; Fri, 20 Feb 2026 21:29:08 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Ju8nKD0r; dkim-atps=neutral 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 3D25E1E08D for ; Fri, 20 Feb 2026 21:29:08 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id A74C24B9DB75 for ; Sat, 21 Feb 2026 02:29:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A74C24B9DB75 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Ju8nKD0r Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 2F4CC4B9DB66 for ; Sat, 21 Feb 2026 02:28:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F4CC4B9DB66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2F4CC4B9DB66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771640923; cv=none; b=WR6X5oi6aUsS2oXE8g+PlXdel+xAhSNGfKvm2aQDz5BS/PXUfxgnjffHr/CdWDmLpnoepIJeAQCax537eQJdaAM5/sAX/X/+dCbw6FH2PFdaTfChH1nTnP16EZFWNq6uQmnL73CtHOSUe9s/WlZWj1UKwqKU6kxW8mYdhsFBRGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771640923; c=relaxed/simple; bh=ihmKSAgp0s08Rg2pWkLUZV0QAptSRCItPUVRcrSsf/Q=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=OGYbgSDcnJzphXe9DbTRHZaRTsgp4Fuo/TNd6Zhqzxy/0tlabttM2mC7XLt0V/DMASaTcYiDE9JSS9hshUSqQV5TqpF2rL+Ne44PJgMfTjyQ99wYums9mgccsnnK0cfyyNFkpUiQXRHPKuG5u9Dm/et4Kk2nH1Q2jvhZubC/UPw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F4CC4B9DB66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1771640919; bh=ihmKSAgp0s08Rg2pWkLUZV0QAptSRCItPUVRcrSsf/Q=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Ju8nKD0rPpJX+iIZiAm5Nt6ikOKTLrhRPwnh5U4xs9PvJmlQ1nXgra1d2Auu37HpQ nC0rcpHp5hyzXc568TXkrBCF9vzj3P9IETL3Tee1ty9GwVAqB+QKAW6gRicZqpCVbP 7j8Z0xsefiHaM9LZImc3gPT7NWqbWHtY5J5M0HMU= Received: by simark.ca (Postfix) id ED1321E08D; Fri, 20 Feb 2026 21:28:38 -0500 (EST) Message-ID: Date: Fri, 20 Feb 2026 21:28:38 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/10] Return gdbpy_ref<> from symbol_to_symbol_object To: Tom Tromey , gdb-patches@sourceware.org References: <20260220-python-safety-minor-v1-0-4c4b12e445af@adacore.com> <20260220-python-safety-minor-v1-2-4c4b12e445af@adacore.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <20260220-python-safety-minor-v1-2-4c4b12e445af@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 On 2026-02-20 16:03, Tom Tromey wrote: > @@ -622,9 +614,10 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) > > if (symbol != nullptr) > { > - PyObject *sym_obj = symbol_to_symbol_object (symbol); > + gdbpy_ref<> sym_obj = symbol_to_symbol_object (symbol); > if (sym_obj == nullptr > - || PyList_Append (return_list.get (), sym_obj) == -1) > + || PyList_Append (return_list.get (), > + sym_obj.get ()) == -1) I asked Claude to review your comments, and it said: Bonus finding: The gdbpy_lookup_static_symbols function in py-symbol.c had a pre-existing reference leak — the old code passed the raw PyObject * from symbol_to_symbol_object directly to PyList_Append (which does its own incref) without decrementing. The new code stores it in a gdbpy_ref<> and passes .get(), fixing the leak. It seems true. It's really hard to remember which functions steal references and which functions get their own new reference. Good job on your part to call .get() here and not .release(). I wish we had a C++ layer around the Python API to make that clear through the type system... Simon