From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00364e01.pphosted.com (mx0a-00364e01.pphosted.com [148.163.135.74]) by sourceware.org (Postfix) with ESMTPS id 79C083858D20 for ; Thu, 31 Aug 2023 19:09:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79C083858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=columbia.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=columbia.edu Received: from pps.filterd (m0167072.ppops.net [127.0.0.1]) by mx0a-00364e01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37VJ65Hh030894 for ; Thu, 31 Aug 2023 15:09:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h=mime-version : references : in-reply-to : from : date : message-id : subject : to : cc : content-type : content-transfer-encoding; s=pps01; bh=z21nUIyVacZE9TOD16c+8eL3HeRSdE64qITspWkYfIg=; b=QE4rK5crR7Ihb7M8JakBC400pj2uiqCdIbSSEXrnafUKESmWFzLEZRkv8VCA4ZlrXUUP FSUccxjwj5Ijp+xUQMVq3ROOPGbCBpjtu9rdYusKsIEWveX465cF9zTl298/CtiPv5CD blAtNiqzQXqAUWnbiUWE+f1bym9MO4ytez9fka37I1XtpPVLvFFWN9NQ0nUf9BgRhBCS JnlGFJqLLbMvEQ7V0YdmVNBYrBfQh+W3O5cYQxGjFlqflWsiyzMQx8751QF09O8HXh0K vw4kqNhZptapmNoQh/QsYjoxAFCAVM2eX3Fc2vEoSv1PgHAkH8poRBJf3lhqb+IHsPBg Xg== Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by mx0a-00364e01.pphosted.com (PPS) with ESMTPS id 3sqdjwhfa5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 31 Aug 2023 15:09:54 -0400 Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-43fa9a00625so336710e0c.2 for ; Thu, 31 Aug 2023 12:09:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693508993; x=1694113793; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z21nUIyVacZE9TOD16c+8eL3HeRSdE64qITspWkYfIg=; b=KqC4EySIgQhzdYppFTDmc2QF3w9XCNHcU1xZJNWIbhh6WsWCzvh+i5Op5QrhCsd/Mb itdC36YEHq5BEDqdHPNC3aAlxl34X+bvbmf9sc/Bf0c2j9aF4bTlpV46ymkmMW1tktMK TQosSApRgjXBnBahL6ZNSVALdw2bLmGxZptFl5OV3OVUYXxGdXIdgf5heFqGElRegSPJ pY0iQ0JNHk5HnojfhwBUFVy8NbL8e/vUInmn/rj5B1pewLtOmUFh6BY+EEFGP9nWAjUP uri314/qxRcxrLwykBU5Xhzis4qNr5INquwkqVF2F6tlrhCnCed/UpP6lPtQcAZ8BHOJ UKwA== X-Gm-Message-State: AOJu0YzDGgK6WW4hksEv6vvEd79van8F7piWYoRmvYlLdmFAydpa88s2 G+7Immq+xT8S2407zVFxB4jJ/mRRD1sVNAVK4T24o5LIpPBCujK0WZeizzDLHcnedEIVApQjgJG 0JZ/QfIYw4WxUZXAh4lir X-Received: by 2002:a1f:e6c3:0:b0:48f:f1cc:a0d3 with SMTP id d186-20020a1fe6c3000000b0048ff1cca0d3mr558178vkh.0.1693508991919; Thu, 31 Aug 2023 12:09:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF8csmXVQKz0kxbgaw4kakIXjGTklozBJSGk1VPXr13TT1oj1nJtADZYarqVfpO845fOpWGwog1KhrhCuOAtE= X-Received: by 2002:a1f:e6c3:0:b0:48f:f1cc:a0d3 with SMTP id d186-20020a1fe6c3000000b0048ff1cca0d3mr558112vkh.0.1693508990839; Thu, 31 Aug 2023 12:09:50 -0700 (PDT) MIME-Version: 1.0 References: <20230829172818.3264-1-ef2648@columbia.edu> <50449b85cd6858842903ad09e102fce2de2785ed.camel@redhat.com> In-Reply-To: <50449b85cd6858842903ad09e102fce2de2785ed.camel@redhat.com> From: Eric Feng Date: Thu, 31 Aug 2023 15:09:39 -0400 Message-ID: Subject: Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646] To: David Malcolm Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 5WAu_FzWP05RIOfkwFguPqvpfmu1orpa X-Proofpoint-GUID: 5WAu_FzWP05RIOfkwFguPqvpfmu1orpa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-31_17,2023-08-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=10 phishscore=0 priorityscore=1501 lowpriorityscore=10 spamscore=0 adultscore=0 bulkscore=10 malwarescore=0 suspectscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308310170 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham 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 Thu, Aug 31, 2023 at 1:01=E2=80=AFPM David Malcolm = wrote: > > On Wed, 2023-08-30 at 18:15 -0400, Eric Feng wrote: > > On Tue, Aug 29, 2023 at 5:14=E2=80=AFPM David Malcolm > > wrote: > > > > > > On Tue, 2023-08-29 at 13:28 -0400, Eric Feng wrote: > > > > Additionally, by using the old model and the pointer per your > > > > suggestion, > > > > we are able to find the representative tree and emit a more > > > > accurate > > > > diagnostic! > > > > > > > > rc3.c:23:10: warning: expected =E2=80=98item=E2=80=99 to have refer= ence count: > > > > =E2=80=981=E2=80=99 > > > > but ob_refcnt field is: =E2=80=982=E2=80=99 > > > > 23 | return list; > > > > | ^~~~ > > > > =E2=80=98create_py_object=E2=80=99: events 1-4 > > > > | > > > > | 4 | PyObject* item =3D PyLong_FromLong(3); > > > > | | ^~~~~~~~~~~~~~~~~~ > > > > | | | > > > > | | (1) when =E2=80=98PyLong_FromLong= =E2=80=99 > > > > succeeds > > > > | 5 | PyObject* list =3D PyList_New(1); > > > > | | ~~~~~~~~~~~~~ > > > > | | | > > > > | | (2) when =E2=80=98PyList_New=E2=80= =99 succeeds > > > > |...... > > > > | 14 | PyList_Append(list, item); > > > > | | ~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > | | | > > > > | | (3) when =E2=80=98PyList_Append=E2=80=99 succeeds, m= oving buffer > > > > |...... > > > > | 23 | return list; > > > > | | ~~~~ > > > > | | | > > > > | | (4) here > > > > | > > > > > > Excellent, that's a big improvement. > > > > > > > > > > > If a representative tree is not found, I decided we should just > > > > bail > > > > out > > > > of emitting a diagnostic for now, to avoid confusing the user on > > > > what > > > > the problem is. > > > > > > Fair enough. > > > > > > > > > > > I've attached the patch for this (on top of the previous one) > > > > below. > > > > If > > > > it also looks good, I can merge it with the last patch and push > > > > it in > > > > at > > > > the same time. > > > > > > I don't mind either way, but please can you update the tests so > > > that we > > > have some automated test coverage that the correct name is being > > > printed in the warning. > > > > > > Thanks > > > Dave > > > > > > > Sorry =E2=80=94 forgot to hit 'reply all' in the previous e-mail. Resen= ding > > to > > preserve our chain on the list: > > > > --- > > > > Thanks; pushed to trunk with nits fixed: > > https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3D597b9ec69bca8acb7a3= d65641c0a730de8b27ed4 > > . > > Thanks; looks good. > > Do you want to add this to the GCC 14 part of the "History" section on > the wiki page: > https://gcc.gnu.org/wiki/StaticAnalyzer > or should I? Happy to add it myself, but I'm not finding an option to edit the page (created an account under efric@gcc.gnu.org). Do I need to be added to the EditorGroup (https://gcc.gnu.org/wiki/EditorGroup) to do so? > > > > > Incidentally, I updated my formatting settings in VSCode, which I've > > previously mentioned in passing. In case anyone is interested: > > > > "C_Cpp.clang_format_style": "{ BasedOnStyle: GNU, UseTab: Always, > > TabWidth: 8, IndentWidth: 2, BinPackParameters: false, > > AlignAfterOpenBracket: Align, > > AllowAllParametersOfDeclarationOnNextLine: true }", > > > > This fixes some issues with the indent width and also ensures > > function > > parameters of appropriate length are aligned properly and on a new > > line each (like the rest of the analyzer code). > > Thanks > Dave > >