Re: GSoC Timeline Review

2024-04-03 Thread Eric Feng via Gcc
Hi Nada, Apologies for not being able to reply earlier as well. I’m glad to hear you’re interested in continuing this project! There is still a lot of work to be done — my work from last summer is in a very prototype stage. As David mentioned, familiarizing myself with the analyzer took some

Re: [PATCH] analyzer: implement symbolic value support for CPython plugin's refcnt checker [PR107646]

2023-09-10 Thread Eric Feng via Gcc
On Thu, Sep 7, 2023 at 1:28 PM David Malcolm wrote: > On Mon, 2023-09-04 at 22:13 -0400, Eric Feng wrote: > > > Hi Dave, > > Hi Eric, thanks for the patch. > > > > > Recently I've been working on symbolic value support for the reference > > count checker. I've attached a patch for it below; let

Re: [PATCH] analyzer: implement symbolic value support for CPython plugin's refcnt checker [PR107646]

2023-09-10 Thread Eric Feng via Gcc-patches
On Thu, Sep 7, 2023 at 1:28 PM David Malcolm wrote: > On Mon, 2023-09-04 at 22:13 -0400, Eric Feng wrote: > > > Hi Dave, > > Hi Eric, thanks for the patch. > > > > > Recently I've been working on symbolic value support for the reference > > count checker. I've attached a patch for it below; let

[PATCH] analyzer: implement symbolic value support for CPython plugin's refcnt checker [PR107646]

2023-09-04 Thread Eric Feng via Gcc
Hi Dave, Recently I've been working on symbolic value support for the reference count checker. I've attached a patch for it below; let me know it looks OK for trunk. Thanks! Best, Eric --- This patch enhances the reference count checker in the CPython plugin by adding support for symbolic

[PATCH] analyzer: implement symbolic value support for CPython plugin's refcnt checker [PR107646]

2023-09-04 Thread Eric Feng via Gcc-patches
Hi Dave, Recently I've been working on symbolic value support for the reference count checker. I've attached a patch for it below; let me know it looks OK for trunk. Thanks! Best, Eric --- This patch enhances the reference count checker in the CPython plugin by adding support for symbolic

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-09-01 Thread Eric Feng via Gcc-patches
Eric Feng > > > > > > From: Eric Feng via Gcc > > > > > gcc/testsuite/ChangeLog: > > > PR analyzer/107646 > > > * gcc.dg/plugin/analyzer_cpython_plugin.c: Implements > > > reference count > > > * checking for PyObjects.

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-09-01 Thread Eric Feng via Gcc
eng > > > > > > From: Eric Feng via Gcc > > > > > gcc/testsuite/ChangeLog: > > > PR analyzer/107646 > > > * gcc.dg/plugin/analyzer_cpython_plugin.c: Implements > > > reference count > > > * checking for PyObjects.

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-31 Thread Eric Feng via Gcc
On Thu, Aug 31, 2023 at 4:19 PM David Malcolm wrote: > > On Thu, 2023-08-31 at 15:09 -0400, Eric Feng wrote: > > On Thu, Aug 31, 2023 at 1:01 PM David Malcolm > > wrote: > > > > > > On Wed, 2023-08-30 at 18:15 -0400, Eric Feng wrote: > > [...] > > > > > > > > > Thanks; pushed to trunk with nits

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-31 Thread Eric Feng via Gcc
On Thu, Aug 31, 2023 at 1:01 PM David Malcolm wrote: > > On Wed, 2023-08-30 at 18:15 -0400, Eric Feng wrote: > > On Tue, Aug 29, 2023 at 5:14 PM David Malcolm > > wrote: > > > > > > On Tue, 2023-08-29 at 13:28 -0400, Eric Feng wrote: > > > > Additionally, by using the old model and the pointer

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-30 Thread Eric Feng via Gcc
On Tue, Aug 29, 2023 at 5:14 PM 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! > > > >

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-30 Thread Eric Feng via Gcc-patches
On Tue, Aug 29, 2023 at 5:14 PM 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! > > > >

[PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-29 Thread Eric Feng via Gcc
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 ‘item’ to have reference count: ‘1’ but ob_refcnt field is: ‘2’ 23 | return list; | ^~~~

[PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-29 Thread Eric Feng via Gcc-patches
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 ‘item’ to have reference count: ‘1’ but ob_refcnt field is: ‘2’ 23 | return list; | ^~~~

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-28 Thread Eric Feng via Gcc-patches
On Tue, Aug 29, 2023 at 12:32 AM Eric Feng wrote: > > Hi Dave, > > Thanks for the feedback. I've addressed the changes you mentioned in > addition to adding more test cases. I've also taken this chance to > split the test files according to known function subclasses, as you previously >

Re: [PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-28 Thread Eric Feng via Gcc
On Tue, Aug 29, 2023 at 12:32 AM Eric Feng wrote: > > Hi Dave, > > Thanks for the feedback. I've addressed the changes you mentioned in > addition to adding more test cases. I've also taken this chance to > split the test files according to known function subclasses, as you previously >

[PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-28 Thread Eric Feng via Gcc-patches
Hi Dave, Thanks for the feedback. I've addressed the changes you mentioned in addition to adding more test cases. I've also taken this chance to split the test files according to known function subclasses, as you previously suggested. Since there were also some changes to the core analyzer,

[PATCH] analyzer: implement reference count checking for CPython plugin [PR107646]

2023-08-28 Thread Eric Feng via Gcc
Hi Dave, Thanks for the feedback. I've addressed the changes you mentioned in addition to adding more test cases. I've also taken this chance to split the test files according to known function subclasses, as you previously suggested. Since there were also some changes to the core analyzer,

Update on CPython Extension Module -fanalyzer plugin development

2023-08-25 Thread Eric Feng via Gcc
Hi Dave, Please find an updated WIP patch on reference count checking below. Some parts aren't properly formatted yet; I apologize for that. Since the last WIP patch, the major updates include: - Updated certain areas of the core analyzer to support custom stmt_finder. - A significant revamp of

Re: Update on CPython Extension Module -fanalyzer plugin development

2023-08-24 Thread Eric Feng via Gcc
On Wed, Aug 23, 2023 at 7:16 PM David Malcolm wrote: > > On Wed, 2023-08-23 at 17:15 -0400, Eric Feng wrote: > > On Mon, Aug 21, 2023 at 11:04 AM David Malcolm > > wrote: > > > > > > On Mon, 2023-08-21 at 10:05 -0400, Eric Feng wrote: > > > > Hi Dave, > > > > > > > > Just wanted to give you and

Re: Update on CPython Extension Module -fanalyzer plugin development

2023-08-23 Thread Eric Feng via Gcc
On Mon, Aug 21, 2023 at 11:04 AM David Malcolm wrote: > > On Mon, 2023-08-21 at 10:05 -0400, Eric Feng wrote: > > Hi Dave, > > > > Just wanted to give you and everyone else a short update on how > > reference count checking is going — we can now observe the refcnt > > diagnostic being emitted: >

Re: Update on CPython Extension Module -fanalyzer plugin development

2023-08-21 Thread Eric Feng via Gcc
: > > Hi Dave, > > Thanks for the feedback! > > > On Wed, Aug 16, 2023 at 5:29 PM David Malcolm wrote: > > > > On Wed, 2023-08-16 at 15:17 -0400, Eric Feng via Gcc wrote: > > > Hi everyone, > > > > [fixing typo in my email address] >

Re: [PATCH] testsuite: Improve test in dg-require-python-h

2023-08-18 Thread Eric Feng via Gcc-patches
Thanks for the patch, Thiago. I've pushed it to trunk: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6785917c9103e18bba0d718ac3b65a386d9a14f7. Best, Eric On Fri, Aug 18, 2023 at 2:11 PM David Malcolm wrote: > > On Thu, 2023-08-17 at 23:30 -0300, Thiago Jung Bauermann wrote: > > If GCC is tested

Re: Update on CPython Extension Module -fanalyzer plugin development

2023-08-16 Thread Eric Feng via Gcc
Hi Dave, Thanks for the feedback! On Wed, Aug 16, 2023 at 5:29 PM David Malcolm wrote: > > On Wed, 2023-08-16 at 15:17 -0400, Eric Feng via Gcc wrote: > > Hi everyone, > > [fixing typo in my email address] > > Hi Eric, thanks for the update, and the WIP patch. > >

Update on CPython Extension Module -fanalyzer plugin development

2023-08-16 Thread Eric Feng via Gcc
Hi everyone, After pushing the code that supports various known function classes last week, I've turned my attention back to the core reference count checking functionality. This functionality used to reside in region_model, which wasn't ideal. To address this, I've introduced a hook to

Re: [COMMITTED] analyzer: More features for CPython analyzer plugin [PR107646]

2023-08-11 Thread Eric Feng via Gcc
I've noticed there were still some strange indentations in the last patch ... however, I think I've finally figured out a sane formatting solution for me (fingers crossed). I will address them in the follow-up patch at the same time as adding more test coverage. --- In case, anyone else using

Re: [COMMITTED] analyzer: More features for CPython analyzer plugin [PR107646]

2023-08-11 Thread Eric Feng via Gcc-patches
I've noticed there were still some strange indentations in the last patch ... however, I think I've finally figured out a sane formatting solution for me (fingers crossed). I will address them in the follow-up patch at the same time as adding more test coverage. --- In case, anyone else using

[COMMITTED] analyzer: More features for CPython analyzer plugin [PR107646]

2023-08-11 Thread Eric Feng via Gcc
Thanks for the feedback! I've incorporated the changes (aside from expanding test coverage, which I plan on releasing in a follow-up), rebased, and performed a bootstrap and regtest on aarch64-unknown-linux-gnu. Since you mentioned that it is good for trunk with nits fixed and no problems after

[COMMITTED] analyzer: More features for CPython analyzer plugin [PR107646]

2023-08-11 Thread Eric Feng via Gcc-patches
Thanks for the feedback! I've incorporated the changes (aside from expanding test coverage, which I plan on releasing in a follow-up), rebased, and performed a bootstrap and regtest on aarch64-unknown-linux-gnu. Since you mentioned that it is good for trunk with nits fixed and no problems after

[COMMITTED] MAINTAINERS: Add myself to write after approval

2023-08-11 Thread Eric Feng via Gcc-patches
ChangeLog: * MAINTAINERS: Add myself. Signed-off-by: Eric Feng --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1e54844c905..7a3ad68bc42 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -411,6 +411,7 @@ Chris Fairles

[PATCH v2] analyzer: More features for CPython analyzer plugin [PR107646]

2023-08-09 Thread Eric Feng via Gcc-patches
Thank you for your help in getting dg-require-python-h working! I can confirm that the FAILs are related to differences between the --cflags affecting the gimple seen by the analyzer. For this reason, I have changed it to --includes for now. To be sure, I tested on Python 3.8 as well and it works

[PATCH v2] analyzer: More features for CPython analyzer plugin [PR107646]

2023-08-09 Thread Eric Feng via Gcc
Thank you for your help in getting dg-require-python-h working! I can confirm that the FAILs are related to differences between the --cflags affecting the gimple seen by the analyzer. For this reason, I have changed it to --includes for now. To be sure, I tested on Python 3.8 as well and it works

[PATCH] WIP for dg-require-python-h [PR107646]

2023-08-08 Thread Eric Feng via Gcc
Unfortunately, there doesn’t seem to be any ERRORs in the .log nor any of the debug print statements which I’ve scattered within proc dg-require-python-h when run. I’ve attached the WIP below; thank you! Please note that in this version of the patch, I’ve removed the other (non Python) test

Re: Update and Questions on CPython Extension Module -fanalyzer plugin development

2023-08-07 Thread Eric Feng via Gcc
On Fri, Aug 4, 2023 at 6:46 PM David Malcolm wrote: > > On Fri, 2023-08-04 at 18:42 -0400, David Malcolm wrote: > > On Fri, 2023-08-04 at 16:48 -0400, Eric Feng wrote: > > > On Fri, Aug 4, 2023 at 11:39 AM David Malcolm > > > wrote: > > > > > > > > On Fri, 2023-08-04 at 11:02 -0400, Eric Feng

Re: Update and Questions on CPython Extension Module -fanalyzer plugin development

2023-08-04 Thread Eric Feng via Gcc
On Fri, Aug 4, 2023 at 11:39 AM David Malcolm wrote: > > On Fri, 2023-08-04 at 11:02 -0400, Eric Feng wrote: > > Hi Dave, > > > > Tests related to our plugin which depend on Python-specific > > definitions have been run by including /* { dg-options "-fanalyzer > > -I/usr/include/python3.9" } */.

Re: Update and Questions on CPython Extension Module -fanalyzer plugin development

2023-08-04 Thread Eric Feng via Gcc
Hi Dave, Tests related to our plugin which depend on Python-specific definitions have been run by including /* { dg-options "-fanalyzer -I/usr/include/python3.9" } */. This is undoubtedly not ideal; is it best to approach this problem by adapting a subset of relevant definitions like in gil.h?

Re: [PATCH v2] analyzer: stash values for CPython plugin [PR107646]

2023-08-03 Thread Eric Feng via Gcc-patches
On Wed, Aug 2, 2023 at 5:09 PM David Malcolm wrote: > > On Wed, 2023-08-02 at 14:46 -0400, Eric Feng wrote: > > On Wed, Aug 2, 2023 at 1:20 PM Marek Polacek > > wrote: > > > > > > On Wed, Aug 02, 2023 at 12:59:28PM -0400, David Malcolm wrote: > > > > On Wed, 2023-08-02 at 12:20 -0400, Eric Feng

Re: [PATCH v2] analyzer: stash values for CPython plugin [PR107646]

2023-08-02 Thread Eric Feng via Gcc-patches
On Wed, Aug 2, 2023 at 1:20 PM Marek Polacek wrote: > > On Wed, Aug 02, 2023 at 12:59:28PM -0400, David Malcolm wrote: > > On Wed, 2023-08-02 at 12:20 -0400, Eric Feng wrote: > > > > Hi Eric, thanks for the updated patch. > > > > Overall, looks good to me, although I'd drop the "Exited." from the

[PATCH v3] analyzer: stash values for CPython plugin [PR107646]

2023-08-02 Thread Eric Feng via Gcc-patches
Revised: -- Remove superfluous { } -- Reword diagnostic --- This patch adds a hook to the end of ana::on_finish_translation_unit which calls relevant stashing-related callbacks registered during plugin initialization. This feature is used to stash named types and global variables for a CPython

Re: [PATCH] analyzer: stash values for CPython plugin [PR107646]

2023-08-02 Thread Eric Feng via Gcc-patches
Hi Dave, Thank you for the feedback! I've incorporated the changes and sent a revised version of the patch. On Tue, Aug 1, 2023 at 1:02 PM David Malcolm wrote: > > On Tue, 2023-08-01 at 09:52 -0400, Eric Feng wrote: > > Hi all, > > > > This patch adds a hook to the end of

[PATCH v2] analyzer: stash values for CPython plugin [PR107646]

2023-08-02 Thread Eric Feng via Gcc-patches
Revised: -- Fix indentation problems -- Add more detail to Changelog -- Add new test on handling non-CPython code case -- Turn off debugging inform by default -- Make on_finish_translation_unit() static -- Remove superfluous null checks in init_py_structs() Changes have been bootstrapped and

Re: Update and Questions on CPython Extension Module -fanalyzer plugin development

2023-08-01 Thread Eric Feng via Gcc
> > My guess is that you were trying to do it from the PLUGIN_ANALYZER_INIT > hook rather than from the plugin_init function, but it's hard to be > sure without seeing the code. > Thanks Dave, you are entirely right — I made the mistake of trying to do it from PLUGIN_ANALYZER_INIT hook and not

[PATCH] analyzer: stash values for CPython plugin [PR107646]

2023-08-01 Thread Eric Feng via Gcc-patches
Hi all, This patch adds a hook to the end of ana::on_finish_translation_unit which calls relevant stashing-related callbacks registered during plugin initialization. This feature is used to stash named types and global variables for a CPython analyzer plugin [PR107646]. Bootstrapped and tested

Re: Update and Questions on CPython Extension Module -fanalyzer plugin development

2023-07-30 Thread Eric Feng via Gcc
[...] > As noted in our chat earlier, I don't think we can easily make these > work. Looking at CPython's implementation: PyList_Type's initializer > here: > https://github.com/python/cpython/blob/main/Objects/listobject.c#L3101 > initializes tp_flags with the flags, but: > (a) we don't see that

Re: Update and Questions on CPython Extension Module -fanalyzer plugin development

2023-07-27 Thread Eric Feng via Gcc
Hi Dave, Thanks for the comments! [...] > Do you have any DejaGnu tests for this functionality? For example, > given PyList_New > https://docs.python.org/3/c-api/list.html#c.PyList_New > there could be a test like: > > /* { dg-require-effective-target python_h } */ > > #define

Update and Questions on CPython Extension Module -fanalyzer plugin development

2023-07-24 Thread Eric Feng via Gcc
Hi all, I would like to update everyone on the progress of the static analyzer plugin for CPython extension module code. Since the last update, I have implemented known function subclasses for PyList_New and PyList_Append. The existing known function subclasses have also been enhanced to provide

Re: Query status of GSoC project: CPyChecker

2023-06-28 Thread Eric Feng via Gcc
Hi Steven, Thanks for reaching out. The project is still in very early stages. So far we have taught the analyzer the basic behavior for PyLong_FromLong, PyList_New, and Py_DECREF via known function subclassing. Additionally, Py_INCREF is supported out of the box. Reference count checking

Re: On inform diagnostics in plugins, support scripts for gdb and modeling creation of PyObjects for static analysis

2023-06-07 Thread Eric Feng via Gcc
Hi Dave, > If that's the code, does it work if you get rid of the "if (0)" > conditional, or change it to "if (1)"? As written, that guard is > false, so that call to "inform" will never be executed. Woops! Somehow I missed that but yes, it works now. Thanks! > Are you invoking gcc from an

On inform diagnostics in plugins, support scripts for gdb and modeling creation of PyObjects for static analysis

2023-06-07 Thread Eric Feng via Gcc
Hi everyone, I am one of the GSoC participants this year — in particular, I am working on a static analyzer plugin for CPython extension module code. I'm encountering a few challenges and would appreciate any guidance on the following issues: 1) Issue with "inform" diagnostics in the plugin: I

Re: Re: GSoC: want to take part in `Extend the static analysis pass for CPython Extension`

2023-04-04 Thread Eric Feng via Gcc
, Apr 3, 2023 at 11:29 AM Martin Jambor wrote: > > Hello, > > On Mon, Apr 03 2023, Eric Feng via Gcc wrote: > > Hi Steven, > > > > I’m happy to collaborate on this project together — it would be great > > to have your experience with CPython internals on the te

Re: Re: GSoC: want to take part in `Extend the static analysis pass for CPython Extension`

2023-04-03 Thread Eric Feng via Gcc
Hi Steven, I’m happy to collaborate on this project together — it would be great to have your experience with CPython internals on the team. > And by the way, I can get to work long before the start-coding time point of > GSoC timeline. I can be involved in some capacity before the

Re: [GSoC] Interest and initial proposal for project on reimplementing cpychecker as -fanalyzer plugin

2023-04-03 Thread Eric Feng via Gcc
Thanks for bringing this to my attention Dave! I’m happy to collaborate on this project with Steven. I will reply in more detail in the other thread. Best, Eric On Sun, Apr 2, 2023 at 7:28 PM David Malcolm wrote: > > On Sat, 2023-04-01 at 19:49 -0400, Eric Feng wrote: > > > For the task above,

Re: [GSoC] Interest and initial proposal for project on reimplementing cpychecker as -fanalyzer plugin

2023-04-01 Thread Eric Feng via Gcc
these declarations require non-NULL args, and thus perhaps we could add > some new macros making the above decls look like: > > PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *) > PyAPI_NonNullArg(1); > > PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t) >

Re: [GSoC] Interest and initial proposal for project on reimplementing cpychecker as -fanalyzer plugin

2023-03-28 Thread Eric Feng via Gcc
look like and how they would help (for example with respect to reference counting semantics)? Incidentally, I forgot to mention in my previous email but I believe the 350-hour option is the one that is more appropriate for this project. Please let me know otherwise. Best, Eric On Sun, Mar 26, 2023

[GSoC] Interest and initial proposal for project on reimplementing cpychecker as -fanalyzer plugin

2023-03-25 Thread Eric Feng via Gcc
Hi GCC community, For GSoC, I am extremely interested in working on the selected project idea with respect to extending the static analysis pass. In particular, porting gcc-python-plugin's cpychecker to a plugin for GCC -fanalyzer as described in