From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4444 invoked by alias); 22 Apr 2013 18:26:29 -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 4432 invoked by uid 89); 22 Apr 2013 18:26:28 -0000 X-Spam-SWARE-Status: No, score=-7.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 22 Apr 2013 18:26:27 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3MIQQ7i013378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 22 Apr 2013 14:26:26 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3MIQOsn003871 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 22 Apr 2013 14:26:25 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Subject: Re: [PATCH 06/28] fix py-evtregistry.c refcount bug References: <87ehe638ww.fsf@fleche.redhat.com> <87bo9a1tk0.fsf@fleche.redhat.com> Date: Tue, 23 Apr 2013 00:23:00 -0000 In-Reply-To: <87bo9a1tk0.fsf@fleche.redhat.com> (Tom Tromey's message of "Fri, 19 Apr 2013 08:30:55 -0600") Message-ID: <874neys9pr.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Virus-Found: No X-SW-Source: 2013-04/txt/msg00682.txt.bz2 --=-=-= Content-Type: text/plain Content-length: 294 >>>>> "Tom" == Tom Tromey writes: Tom> The checker found a refcounting bug in py-evtregistry.c. Tom> This fixes it. It also adds CPYCHECKER_STEALS_REFERENCE_TO_ARG. Tom> I think I meant to split this patch and forgot, sorry about that. I went ahead and split this. Tom --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0007-fix-py-evtregistry.c-refcount-bug.patch Content-Description: fix py-evtregistry.c refcount bug Content-length: 898 >From c2dee2f4e0c0665fe308e596969d5bb3076fdc09 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 22 Apr 2013 12:23:19 -0600 Subject: [PATCH 07/33] fix py-evtregistry.c refcount bug The checker found a refcounting bug in py-evtregistry.c. * py-evtregistry.c (create_event_object): Decref eventregistry_object if PyList_New fails. --- gdb/python/py-evtregistry.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c index c8003af..05c8586 100644 --- a/gdb/python/py-evtregistry.c +++ b/gdb/python/py-evtregistry.c @@ -89,7 +89,10 @@ create_eventregistry_object (void) eventregistry_obj->callbacks = PyList_New (0); if (!eventregistry_obj->callbacks) - return NULL; + { + Py_DECREF (eventregistry_obj); + return NULL; + } return eventregistry_obj; } -- 1.8.1.4 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0008-add-CPYCHECKER_STEALS_REFERENCE_TO_ARG.patch Content-Description: add CPYCHECKER_STEALS_REFERENCE_TO_ARG Content-length: 1959 >From 8091b73a70c56a7be474c23efa2a8ab598a7b186 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 22 Apr 2013 12:23:48 -0600 Subject: [PATCH 08/33] add CPYCHECKER_STEALS_REFERENCE_TO_ARG The checker provides an attribute that can be used to indicate that a function steals a reference to an argument. This patch adds a macro for this attribute to gdb and changes one spot to use it. * python/py-event.h (evpy_emit_event): Use CPYCHECKER_STEALS_REFERENCE_TO_ARG. * python/python-internal.h (CPYCHECKER_STEALS_REFERENCE_TO_ARG): New macro. --- gdb/python/py-event.h | 3 ++- gdb/python/python-internal.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h index 970595b..1db8bd2 100644 --- a/gdb/python/py-event.h +++ b/gdb/python/py-event.h @@ -106,7 +106,8 @@ extern int emit_continue_event (ptid_t ptid); extern int emit_exited_event (const LONGEST *exit_code, struct inferior *inf); extern int evpy_emit_event (PyObject *event, - eventregistry_object *registry); + eventregistry_object *registry) + CPYCHECKER_STEALS_REFERENCE_TO_ARG (1); extern PyObject *create_event_object (PyTypeObject *py_type); extern PyObject *create_thread_event_object (PyTypeObject *py_type); diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 394a148..5fbb472 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -34,6 +34,13 @@ #define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG) #endif +#ifdef WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE +#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \ + __attribute__ ((cpychecker_steals_reference_to_arg (n))) +#else +#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) +#endif + #include /* Python 2.4 doesn't include stdint.h soon enough to get {u,}intptr_t -- 1.8.1.4 --=-=-=--