From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2D73F3858D28 for ; Tue, 29 Aug 2023 21:08:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D73F3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693343324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4m/U2hWV2WiAOBp7Wh/eTAa2l3636D5ogNOiYP+jX2g=; b=OzaoCCcaXoBjnwGmNr2L9MU1kW5bEhaL7Z85gKGzoT0MnoL+zGO1C00dLDajz6pl7jUwc0 SsZ5AOhn7DvnuQC50iUTSq7uKQP09uT4//Ug4PwpQujd+XbdJas5sjXXReNLlga2dUmw+f zhDZ9B01lMmfuIOGs9TQQjdSGfmUdXQ= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-QbtlvYJPMZa46Rz1dqTxnw-1; Tue, 29 Aug 2023 17:08:43 -0400 X-MC-Unique: QbtlvYJPMZa46Rz1dqTxnw-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-76da52a42bcso601582685a.3 for ; Tue, 29 Aug 2023 14:08:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693343322; x=1693948122; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=i+mKh+yfWyh5FOgwtMuDbeCL6P7SNQRkckEKJm0PANY=; b=ZZM4cUXfIorhtJ9y+szyNd/FuQWbqqEGopM5MTw3neFtHMkD9QLp34UIkgExDdgcxI nPEmG7G2BJk/1zSS8RuijvoNRgGo1MJ++zhcsDL4BoxTdUOWJ0cU4fDS5B8U03SwchwI i7BtGkzndz2gin05Oddjg5SZEN+eNh2tfFlBo0io3y2YLb6LHWMHbtl7/gjR7LdzJ+iR 2zJh4KWoALvEXObj1jAlT/y/DySbBWXj7yXnFD5K7xirRzRXLvxsPh859VXgtfMBkG4r ANGGjataamwaZdKM6WNU6HYvh4d21T7L6KnstFtQrXVbCm7511E3r2CWZ7XUVtyMZJRm 74bg== X-Gm-Message-State: AOJu0YxRigZxFADq3IdYH6QFRqOpjFVOtWLyIoOmGr1sze7gpyZLam87 tyPsnqf8Vo1vUwduhvyLPo8zYZMMvTPs/MTMv0znNYOr9xR8ey/Pa+qWpuWLni4s19lU7IxMpxm TZFNHcCU+SKHoMEU= X-Received: by 2002:a05:620a:45a2:b0:76c:e351:6746 with SMTP id bp34-20020a05620a45a200b0076ce3516746mr181724qkb.56.1693343322521; Tue, 29 Aug 2023 14:08:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvtPub/ZrqDU9y2gQQM3JOKLZ793weNspeUYrzXmaf4fDjLHywHEiXgRGTw0uX/zXkK5DVRw== X-Received: by 2002:a05:620a:45a2:b0:76c:e351:6746 with SMTP id bp34-20020a05620a45a200b0076ce3516746mr181704qkb.56.1693343322226; Tue, 29 Aug 2023 14:08:42 -0700 (PDT) Received: from t14s.localdomain (c-76-28-97-5.hsd1.ma.comcast.net. [76.28.97.5]) by smtp.gmail.com with ESMTPSA id r9-20020ac84249000000b0040554ed322dsm3246488qtm.62.2023.08.29.14.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 14:08:41 -0700 (PDT) Message-ID: Subject: Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646] From: David Malcolm To: Eric Feng Cc: gcc@gcc.gnu.org, gcc-patches@gcc.gnu.org Date: Tue, 29 Aug 2023 17:08:40 -0400 In-Reply-To: <20230829043155.17651-1-ef2648@columbia.edu> References: <20230829043155.17651-1-ef2648@columbia.edu> User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 2023-08-29 at 00:31 -0400, Eric Feng wrote: > Hi Dave, Hi Eric. Thanks for the updated patch. A few nits below; this is OK for trunk with them fixed... [...snip...] >=20 > gcc/analyzer/ChangeLog: > PR analyzer/107646 > =09* engine.cc (impl_region_model_context::warn): New optional parameter. > =09* exploded-graph.h (class impl_region_model_context): Likewise. > =09* region-model.cc (region_model::pop_frame): New callback feature for > * region_model::pop_frame. > =09* region-model.h (struct append_regions_cb_data): Likewise. > =09(class region_model): Likewise. > =09(class region_model_context): New optional parameter. > =09(class region_model_context_decorator): Likewise. >=20 > gcc/testsuite/ChangeLog: > PR analyzer/107646 > =09* gcc.dg/plugin/analyzer_cpython_plugin.c: Implements reference count > * checking for PyObjects. > =09* gcc.dg/plugin/cpython-plugin-test-2.c: Moved to... > =09* gcc.dg/plugin/cpython-plugin-test-PyList_Append.c: ...here (and > * added more tests). > =09* gcc.dg/plugin/cpython-plugin-test-1.c: Moved to... > =09* gcc.dg/plugin/cpython-plugin-test-no-plugin.c: ...here (and added > * more tests). > =09* gcc.dg/plugin/plugin.exp: New tests. > =09* gcc.dg/plugin/cpython-plugin-test-PyList_New.c: New test. > =09* gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c: New test. > =09* gcc.dg/plugin/cpython-plugin-test-refcnt-checking.c: New test. The ChangeLog formatting here seems wrong; lines starting with a '*' should refer to a filename. Continuation lines begin with just a tab character. [...snip...] > diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h > index 10b2a59e787..440ea6d828d 100644 > --- a/gcc/analyzer/region-model.h > +++ b/gcc/analyzer/region-model.h [...snip...] > @@ -840,7 +865,8 @@ private: > class region_model_context_decorator : public region_model_context > { > public: > - bool warn (std::unique_ptr d) override > + bool warn (std::unique_ptr d, > +=09 const stmt_finder *custom_finder) > { > if (m_inner) > return m_inner->warn (std::move (d)); This should presumably pass the custom_finder on to the 2nd argument of m_inner->warn, rather than have the inner call to warn implicitly use the NULL default arg. [...snip...] > diff --git a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-1.c b/gcc/te= stsuite/gcc.dg/plugin/cpython-plugin-test-no-plugin.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-1.c > rename to gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-no-plugin.c Looks like "-no-Python-h.c" would be a better suffix than "-no-plugin.c" as it's the include that's missing, not the plugin. [...snip...] > diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.d= g/plugin/plugin.exp > index e1ed2d2589e..cbef6da8d86 100644 > --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp > +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp > @@ -161,8 +161,9 @@ set plugin_test_list [list \ > =09 taint-CVE-2011-0521-6.c \ > =09 taint-antipatterns-1.c } \ > { analyzer_cpython_plugin.c \ > -=09 cpython-plugin-test-1.c \ > -=09 cpython-plugin-test-2.c } \ > +=09 cpython-plugin-test-PyList_Append.c \ > +=09 cpython-plugin-test-PyList_New.c \ > +=09 cpython-plugin-test-PyLong_FromLong.c } \ Looks like this is missing: cpython-plugin-test-no-plugin.c and cpython-plugin-test-refcnt-checking.c (though as noted above"cpython-plugin-test-no-Python-h.c" would be a better name for the former) so it wasn't actually compiling these tests. Be sure to doublecheck that these tests pass when updating. [...snip...] OK for trunk with the above nits fixed. Dave