New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference leaks introduced by bpo-30860 #75601
Comments
The following commands show memory leaks introduced by bpo-30860: $ ./python -m test -R 3:3 test_atexit -m test.test_atexit.SubinterpreterTest.test_callbacks_leak
$ ./python -m test -R 3:3 test_atexit -m test.test_atexit.SubinterpreterTest.test_callbacks_leak_refcycle
$ ./python -m test -R 3:3 test_threading -m test.test_threading.SubinterpThreadingTests.test_threads_join
$ ./python -m test -R 3:3 test_capi -m test.test_capi.SubinterpreterTest.test_subinterps |
Oh, I'm talking about the commit 2ebc5ce. |
Could be the same as bpo-31408. |
The leak comes from the following lines of _PySys_EndInit(): PyObject *warnoptions = get_warnoptions();
if (warnoptions == NULL)
return -1;
SET_SYS_FROM_STRING_BORROW_INT_RESULT("warnoptions", warnoptions);
PyObject *xoptions = get_xoptions();
if (xoptions == NULL)
return -1;
SET_SYS_FROM_STRING_BORROW_INT_RESULT("_xoptions", xoptions); It's not the first time that I have an issue with these attributes. The last reference weak caused by multiple interpreters was also related to this one if I recall correctly. |
Extract of my msg295399: "The problem is that warnoptions is stored in a C global variable *and* in sys.warnoptions of each interpreter. The ownership of this variable is unclear." Maybe we need a change similar to bpo-28411 (commit 86b7afd) which removed the "modules" field from Py_InterpreterState. |
I'm looking into this. |
Moving warnoptions (and xoptions) out of PyInterpreterState seems like a good idea to me for the same reasons as applied to sys.modules. The case for these two is even stronger since they are only used in sysmodule.c. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: