-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
[TraceRefs build] Tests fail: _PyRefchain_Remove: Assertion `value == REFCHAIN_VALUE' failed #124785
Comments
The bug can be reproduced with: import _testcapi; _testcapi.run_in_subinterp(f"raise ValueError") The regression was introduced by commit 98b2ed7:
|
My guess would be it's due to the incref on the interned_dict from the main interpreter. Perhaps we should remove that incref and corresponding decref. Eric told me to leave it out when he was helping with the patch. |
Unfortunately (because that should be a simple fix), that doesn't seem to be the problem. The traceback I see:
That suggests to me that when the main interpreter is cleaning up, it's confused by the immortal interned strings coming from sub-interpreters. I'm still working on it. |
@pablogsal thinks breaking the trace-refs build could be a release blocker for 3.13 so let's try to fix this quickly. I noticed that the logic that decides to copy the extension module dict is not the same as my Changing my function to look at that flag doesn't fix it though. It seems |
Would it help to make use of |
(labelling it as release blocker to force the RM to decide, sorry =) |
I think commit 98b2ed7 should get reverted if trace-refs failures is a release blocker. I'm not coming up with a simple fix for that. Reverting means that Python embedding programs like Weechat and Kodi will likely crash due to them using "basic single-phase init" extensions. So, I'm not really sure the cure is worse than the disease, so to speak. I'm working on an alternative to 98b2ed7 that just leaks those strings. I think that could be simpler and safer to include in 3.12 and 3.13. Sharing the interned_strings with the main interpreter could have other unexpected side-effects and leaking is perhaps better. |
I'm not sure but i don't think so. The problem is likely here:
when this runs in the main interpreter. I think those |
The pythongh-124646 fix has the issue that it breaks the trace-refs debug build. This is a simpler fix that avoids the use-after-free crashes by just leaking immortal interned strings allocated by legacy subinterpreters.
The pythonGH-124646 fix has the issue that it breaks the trace-refs debug build. This is a simpler fix that avoids the use-after-free crashes by just leaking immortal interned strings allocated by legacy subinterpreters.
…ortal interned strings (pythongh-124646)" (pythongh-124807) Revert "pythongh-116510: Fix crash due to shared immortal interned strings. (pythongh-124646)" This reverts commit 98b2ed7. (cherry picked from commit 7bdfabe) Co-authored-by: T. Wouters <thomas@python.org>
… interned strings (gh-124646)" (gh-124807) (#124812) gh-124785: Revert "gh-116510: Fix crash due to shared immortal interned strings (gh-124646)" (gh-124807) Revert "gh-116510: Fix crash due to shared immortal interned strings. (gh-124646)" This reverts commit 98b2ed7. (cherry picked from commit 7bdfabe) Co-authored-by: T. Wouters <thomas@python.org>
…red immortal interned strings (pythongh-124646)" (pythongh-124807) Revert "pythongh-116510: Fix crash due to shared immortal interned strings. (pythongh-124646)" This reverts commit 98b2ed7. (cherry picked from commit 7bdfabe) Co-authored-by: T. Wouters <thomas@python.org>
This should now be fixed, but of course the original issue is still open. |
…ared immortal interned strings (pythongh-124646)" (pythongh-124807)" This reverts commit 7bdfabe.
FYI, it looks like the problem is that the immortal interned strings were added to the subinterpreter's "refchain" but should have been on the main interpreter's, since they were now tied to the main interpreter's lifecycle. The failing assertion1 was hit while finalizing the main interpreter because the refchain the object was originally bound to belonged to the subinterpreter, which was already finalized. I've posted a fix: gh-124865. (This does make we wonder if all immortal objects from legacy interpreters (sharing the main interpreter's obmalloc) should be forced onto the main interpreter's refchain. We can work that out separately.) Footnotes
|
…4865) Fix a crash caused by immortal interned strings being shared between sub-interpreters that use basic single-phase init. In that case, the string can be used by an interpreter that outlives the interpreter that created and interned it. For interpreters that share obmalloc state, also share the interned dict with the main interpreter. This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS failures identified by gh-124785.
…ythongh-124865) Fix a crash caused by immortal interned strings being shared between sub-interpreters that use basic single-phase init. In that case, the string can be used by an interpreter that outlives the interpreter that created and interned it. For interpreters that share obmalloc state, also share the interned dict with the main interpreter. This is an un-revert of pythongh-124646 that then addresses the Py_TRACE_REFS failures identified by pythongh-124785. (cherry picked from commit f2cb399) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
…ythongh-124865) Fix a crash caused by immortal interned strings being shared between sub-interpreters that use basic single-phase init. In that case, the string can be used by an interpreter that outlives the interpreter that created and interned it. For interpreters that share obmalloc state, also share the interned dict with the main interpreter. This is an un-revert of pythongh-124646 that then addresses the Py_TRACE_REFS failures identified by pythongh-124785. (cherry picked from commit f2cb399) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
…gh-124865) (gh-125709) (GH-125204) * gh-116510: Fix a Crash Due to Shared Immortal Interned Strings (gh-124865) Fix a crash caused by immortal interned strings being shared between sub-interpreters that use basic single-phase init. In that case, the string can be used by an interpreter that outlives the interpreter that created and interned it. For interpreters that share obmalloc state, also share the interned dict with the main interpreter. This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS failures identified by gh-124785. (cherry picked from commit f2cb399) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com> * [3.13] gh-125286: Share the Main Refchain With Legacy Interpreters (gh-125709) They used to be shared, before 3.12. Returning to sharing them resolves a failure on Py_TRACE_REFS builds. --------- Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
…gh-125205) Fix a crash caused by immortal interned strings being shared between sub-interpreters that use basic single-phase init. In that case, the string can be used by an interpreter that outlives the interpreter that created and interned it. For interpreters that share obmalloc state, also share the interned dict with the main interpreter. This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS failures identified by gh-124785 (i.e. backporting gh-125709 too). (cherry picked from commit f2cb399, AKA gh-124865) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Multiple tests fail on a TraceRefs build: https://buildbot.python.org/#/builders/484/builds/5981
Examples of errors:
Linked PRs
The text was updated successfully, but these errors were encountered: