From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15183 invoked by alias); 13 Sep 2018 05:30:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 14980 invoked by uid 89); 13 Sep 2018 05:30:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_RP_RNBL,SPF_HELO_PASS autolearn=no version=3.3.2 spammy= X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.91) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Sep 2018 05:30:29 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 64345400C8324 for ; Thu, 13 Sep 2018 00:30:11 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 0KChg0CdFRPoj0KChgNWvi; Thu, 13 Sep 2018 00:30:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=N8g76c95ckohShnifTLvkos+6EgUA7NT+ew6LayLdNo=; b=WzuD4uYcQaqVgfWNoYtePZQJuP Irp4oqRLh4QlI7rjvwnQKu5ZIzeWkxfHKeRdLmTGs+4kXPdfE/8C33hUh5/tCELr/LbVljRvq75Pr DFU+AKYqc4e6lbIkca+UQ7U3n; Received: from 97-122-189-157.hlrn.qwest.net ([97.122.189.157]:54318 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g0KCh-0045EG-4J for gdb-patches@sourceware.org; Thu, 13 Sep 2018 00:30:11 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 0/4] Disallow the return of borrowed references Date: Thu, 13 Sep 2018 05:30:00 -0000 Message-Id: <20180913053007.11780-1-tom@tromey.com> X-SW-Source: 2018-09/txt/msg00412.txt.bz2 While working on a different Python patch, I misread pspace_to_pspace_object and thought it was not handling reference counts properly. It is -- but I found it difficult to reason about because it returns a borrowed reference, but uses gdbpy_ref as well. This series changes gdb so that none of the Python functions will return a borrowed reference. These functions are modified instead to return a new reference using gdbpy_ref<>, which not only makes the intent clear, but also makes it more difficult to have a buggy caller. This could go further and make all functions return gdbpy_ref<>. (Even Python-facing ones could be done via template fuction wrappers.) However I have not done this. I think now gdb should disallow Python functions returning borrowed references. Accepting a borrowed reference is still ok, and I think should continue to be. I think this series found at least one bug: infpy_thread_from_thread_handle could return None without incref'ing it. Let me know what you think. I tested this on x86-64 Fedora 28. Tom