This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FWIW, I'm not convinced we should add this (as I noted on the tracker issue). So I've marked the PR DO-NOT-MERGE until that question has been resolved.
interp->dict leaks when the PyInterpreterState is destroyed. Please Py_CLEAR() it! Also, make sure it is done at the very last moment; otherwise, race conditions can recreate interp->dict after it was cleared, and then that would leak.
@arigo, thanks for noticing that. Something was nagging at me and I couldn't figure out what. You saved me some time. :) That's what I get for hurrying out a PR at the end of the day!
When you are talking about "at the very last moment", you mean after everything has been cleared which might cause interp->dict to get re-created during its __del__()? Isn't that mostly true of everything that gets cleared in PyInterpreterState_Clear()? Regardless, I'm clearing it almost at the end. Only the "at-fork" handlers are later.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This parallels
PyThreadState.dict. Likewise we addPyInterpreterState_GetDict().https://bugs.python.org/issue36124