-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters #107567
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
Changes from 4 commits
11d48cd
238e00f
33105c0
ac78d7b
e21c558
7a8e549
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Trace refs builds (``--with-trace-refs``) were crashing when used with | ||
isolated subinterpreters. The problematic global state has been isolated to | ||
each interpreter. Other fixing the crashes, this change does not affect | ||
users. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1921,12 +1921,15 @@ Py_FinalizeEx(void) | |
} | ||
|
||
if (dump_refs) { | ||
_Py_PrintReferences(stderr); | ||
_Py_PrintReferences(tstate->interp, stderr); | ||
} | ||
|
||
if (dump_refs_fp != NULL) { | ||
_Py_PrintReferences(dump_refs_fp); | ||
_Py_PrintReferences(tstate->interp, dump_refs_fp); | ||
} | ||
|
||
PyObject refchain = { 0 }; | ||
_Py_StealRefchain(tstate->interp, &refchain); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The interpreter will be deallocated before we later call That said, I think there's a related problem that I still need to address. Namely, every remaining object in the linked list will be (effectively) freed when the interpreter's allocator is finalized, so the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I'm pretty sure that's not actually a problem. We only call |
||
#endif /* Py_TRACE_REFS */ | ||
|
||
/* At this point there's almost no other Python code that will run, | ||
|
@@ -1961,11 +1964,11 @@ Py_FinalizeEx(void) | |
*/ | ||
|
||
if (dump_refs) { | ||
_Py_PrintReferenceAddresses(stderr); | ||
_Py_PrintReferenceAddresses(&refchain, stderr); | ||
} | ||
|
||
if (dump_refs_fp != NULL) { | ||
_Py_PrintReferenceAddresses(dump_refs_fp); | ||
_Py_PrintReferenceAddresses(&refchain, dump_refs_fp); | ||
fclose(dump_refs_fp); | ||
} | ||
#endif /* Py_TRACE_REFS */ | ||
|
Uh oh!
There was an error while loading. Please reload this page.