Skip to content

Commit 4bb96fc

Browse files
[3.15] gh-159739: Avoid destroying a remote unwinder cache twice (GH-159982) (#160023)
In a free-threaded build, if allocating the thread-local bytecode cache fails after the code-object cache has been created, the initializer destroys the first cache and returns an error without clearing its pointer. Failed construction then invokes the unwinder's deallocator, which destroys the same cache again and can crash the profiling process instead of propagating `MemoryError`. (cherry picked from commit b577a54) Co-authored-by: Jelle Zijlstra <jelle@openai.com>
1 parent 2d4adac commit 4bb96fc

2 files changed

Lines changed: 1 addition & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a double free if remote unwinder initialization runs out of memory.

‎Modules/_remote_debugging/module.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ _remote_debugging_RemoteUnwinder___init___impl(RemoteUnwinderObject *self,
450450
NULL
451451
);
452452
if (self->tlbc_cache == NULL) {
453-
_Py_hashtable_destroy(self->code_object_cache);
454453
PyErr_NoMemory();
455454
set_exception_cause(self, PyExc_MemoryError, "Failed to create TLBC cache");
456455
return -1;

0 commit comments

Comments
 (0)