Skip to content

bpo-38858: Fix ref leak in pycore_interp_init()#17512

Merged
vstinner merged 1 commit intopython:masterfrom
vstinner:fix_sys_create
Dec 8, 2019
Merged

bpo-38858: Fix ref leak in pycore_interp_init()#17512
vstinner merged 1 commit intopython:masterfrom
vstinner:fix_sys_create

Conversation

@vstinner
Copy link
Copy Markdown
Member

@vstinner vstinner commented Dec 8, 2019

bpo-38858, bpo-38997: _PySys_Create() returns a strong reference to
the sys module: Py_DECREF() is needed when we are done with the
module.

https://bugs.python.org/issue38858

@vstinner
Copy link
Copy Markdown
Member Author

vstinner commented Dec 8, 2019

I tested manually that this change fix https://bugs.python.org/issue38997:

$ ./python -m test -R 3:3 -j0  test__xxsubinterpreters test_atexit test_capi test_threading
(...)
All 4 tests OK.

Total duration: 1 min 2 sec
Tests result: SUCCESS

This bug is not a regression: it exists at least since Python 2.7. It's just that previously, the bug was hidden because subinterpreters were not well isolated from the main interpreter.

@ericsnowcurrently: Welcome to the hell of correctness enforced by subinterpreters :-)

bpo-38858, bpo-38997: _PySys_Create() returns a strong reference to
the sys module: Py_DECREF() is needed when we are done with the
module.
@vstinner
Copy link
Copy Markdown
Member Author

vstinner commented Dec 8, 2019

If this change is merged, PR #17509 can be rejected.

@vstinner vstinner merged commit 080ee5a into python:master Dec 8, 2019
@vstinner vstinner deleted the fix_sys_create branch December 8, 2019 20:56
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 2020
bpo-38858, bpo-38997: _PySys_Create() returns a strong reference to
the sys module: Py_DECREF() is needed when we are done with the
module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants