You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gh-146308: Fix error handling issues in _remote_debugging module
- Fix double-free in parse_code_object when cache insertion fails:
NULL out locals before cached_code_metadata_destroy to prevent
the error label's Py_XDECREF from double-freeing.
- Fix memory leak in reader_get_or_create_thread_state: use temp
variable for grow_array return to avoid losing the original pointer
on realloc failure.
- Fix half-initialized thread state entry: defer thread_state_count
increment until after successful current_stack allocation to prevent
future lookups from finding a broken entry with NULL current_stack.
- Add varint decode error checks in decode_stack_full/suffix/pop_push:
use offset-comparison pattern (consistent with rest of file) to detect
malformed data that would otherwise cause infinite loops or silent
corruption. Also replace PyErr_Occurred() with offset-comparison in
decode_varint_u32/i32 for consistency and to avoid TLS lookups in
the hot decode path.
- Fix missing PyErr_SetString before set_exception_cause at 4 sites
where the macro's assert(PyErr_Occurred()) would fire in debug builds:
object_reading.c (read_py_long size validation), asyncio.c (coro chain
size check), and code_objects.c (two _Py_hashtable_set failure paths).
- Fix reference leak in process_frame_chain: add Py_XDECREF(frame)
on error paths in the extra-frame insertion block.
- Fix macOS thread_id_offset using 0 as "not computed" sentinel when 0
is a valid offset: add explicit thread_id_offset_initialized flag.
- Make get_thread_status return THREAD_STATE_UNKNOWN on all failure
paths across all platforms (previously Windows/macOS returned -1
without setting a Python exception, leaving dangling exceptions
since the caller doesn't check PyErr_Occurred). Update caller to
compare against THREAD_STATE_UNKNOWN instead of -1.
- Clear sample_data pointer after munmap in binary_reader_close to
prevent dangling pointer to unmapped memory.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments