This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: some leak in the compiler_assert function
Type: resource usage Stage: resolved
Components: Interpreter Core Versions: Python 3.9
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: pablogsal, pitrou, serhiy.storchaka, shihai1991, vstinner
Priority: normal Keywords: patch

Created on 2019-08-19 14:55 by shihai1991, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit
compiler_assert.patch shihai1991, 2019-08-19 14:55
Messages (4)
msg349959 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2019-08-19 14:55
Some reference leak in compiler_assert function, due to not using  Py_DECREF(assertion_error) before return. And having a question about code order in compiler_assert function.
msg349982 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-08-20 00:11
Hi hai shi,

As you can see in other pars of the code base objects returned from PyUnicode_InternFromString that have static storage class do not need to be deallocated in case there is a failure, so this is not considered a leak as there will be only one owned object across all calls. The Python object is reused every time the function is call (so in successive calls the object can be reused and therefore assertion_error!= NULL).
msg349992 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-20 06:41
Thank you for your patch hai shi. But note that assertion_error is a static variable. It is initialized only once. Your change makes it holding a borrowed reference after first call of compiler_assert(). This does not look reliable.

In any case assertion_error will gone after resolving issue34880, so I am closing this issue in favor of that.

If not issue34880, it would be better to use a private API for _Py_IDENTIFIER here.
msg349999 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2019-08-20 11:34
Ok, got it.
Date User Action Args
2022-04-11 14:59:19adminsetgithub: 82068
2019-08-20 11:34:26shihai1991setmessages: + msg349999
2019-08-20 06:41:53serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg349992

resolution: rejected
stage: resolved
2019-08-20 00:11:48pablogsalsetnosy: + pablogsal
messages: + msg349982
2019-08-19 14:55:03shihai1991create