Skip to content

Commit b577a54

Browse files
authored
gh-159739: Avoid destroying a remote unwinder cache twice (#159982)
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`.
1 parent fab1405 commit b577a54

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)