32 Commits
Author SHA1 Message Date
Jelle Zijlstra b577a5403a 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`.
2026-10-20 21:38:55 -07:00
Maurycy Pawłowski-WierońskiandPablo Galindo Salgado f839c061d3 gh-151292: _remote_debugging: Do not corrupt the binary file when hitting OverflowError (#152892)
* the kolektor

* test

* better test

* news

* =Q, move const to the base, not self.running

* gh-151292: Track binary writer finalization state

---------

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2026-10-05 01:04:20 +00:00
Shankar Rao S PatilandPablo Galindo Salgado 72f821fdb8 gh-149302: Fix incorrect docstring in RemoteUnwinder.get_all_awaited_by (#149312)
* Fix incorrect docstring for get_all_awaited_by in _remote_debugging

* Regenerate Argument Clinic output after docstring fix

* Clarify task waiter relationships and fallback task list

---------

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2026-10-04 21:29:13 +00:00
Pablo Galindo Salgado d3663ef943 gh-154090: Store profiling mode and capture settings in binary profiles (GH-154105) 2026-09-24 23:17:30 +00:00
Pablo Galindo Salgado 7f0ccd6c0e gh-154060: Preserve replay duration and rate (#154101) 2026-08-26 10:24:00 +01:00
Serhiy StorchakaandClaude Opus 5 2c47c65f2e gh-156261: Move converters used in several files to Argument Clinic (GH-156262)
The pid_t, Py_off_t, HANDLE, DWORD and BOOL converters were defined in
9 files.  The Py_off_t type and its converter function are now shared too.
DWORD in _winapi is used with bitwise=True to keep accepting negative
values.

The pid_t converter is now used for the pid parameters in the
_remote_debugging module, which were declared as int.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 19:47:55 +03:00
Maurycy Pawłowski-Wieroński 1d196507e6 gh-151292: Change total_samples:u32 in the binary format to total_samples:u64 (#153425) 2026-07-09 13:59:28 +00:00
Maurycy Pawłowski-Wieroński 639a5525fb gh-151378: Fix unbounded memory growth when recording binary and the thread is sleeping (#152089) 2026-07-04 20:03:01 +01:00
Pablo Galindo Salgado 8cda6ae2f1 gh-151613: Fix remote debugging frame cache ABA (#151614)
The remote debugging frame cache previously used only the last_profiled_frame address as its cache anchor. If a frame returned and a later frame reused the same _PyInterpreterFrame address, the profiler could accept a stale cache entry and splice parent frames from a different call chain into the current stack.

This adds a last_profiled_frame_seq counter next to last_profiled_frame, increments it when the anchor advances, stores it in frame cache entries, and validates cache hits against both the frame address and the sequence. Cache miss walks now copy stack chunks before storing new cache entries so stored continuations come from a stable snapshot. The new regression test exercises alternating call chains and checks that cached stacks never contain frames from both branches.
2026-06-27 16:56:31 +00:00
sobolevn a173a6d65b gh-151584: Remove PyUnstable_Module_SetGIL call in _remote_debugging (#151585) 2026-06-17 15:37:08 +03:00
Pablo Galindo Salgado a5be25d3bd gh-149619: Harden _remote_debugging error paths (#150349) 2026-05-25 23:22:46 +01:00
Serhiy Storchaka cdc499ae77 gh-150285: Fix too long docstrings in the _remote_debugging module (GH-150289) 2026-05-24 15:02:43 +03:00
Pablo Galindo Salgado 661df25692 gh-149584: Fix excessive overhead in the Tachyon profiler regarding the cache behavior (#149649)
Use exact remote reads for interpreter state, thread state, and
interpreter frame structs instead of pulling full remote pages into the
profiler page cache. This matches the core change from
python/cpython#149585.

The profiler clears the page cache between samples, so live entries are
always packed at the front. Track the live count and only clear/search
that prefix instead of scanning all 1024 slots on the hot path.

Use the frame cache to predict the next thread state and top frame
address, then batch interpreter/thread/frame reads with process_vm_readv
when profiling a Linux target. Reuse prefetched frame buffers in the
frame walker when the prediction is valid.

Cache the last FrameInfo tuple per code object/instruction offset, reuse
cached thread id objects, and append cached parent frames directly on
full frame-cache hits. This cuts Python allocation churn in the
steady-state profiler path.
2026-05-20 04:32:08 -07:00
Maurycy Pawłowski-Wieroński 354ef336e4 gh-149474: use Py_fopen in Binary{Reader,Writer} for audit hook and path-like support (#149524) 2026-05-09 01:01:35 +01:00
Maurycy Pawłowski-Wieroński 6f8c964dc0 gh-149342: _remote_debugging: Fix binary profile corruption when sampling a (temporarily) empty stack (#149343) 2026-05-05 00:32:06 +00:00
Sergey Miryanov e89568f0cb GH-148726: Add heap_size to generational GC (#149195) 2026-05-04 22:14:45 +01:00
Sergey Miryanov 39f123c587 GH-146527: Add get_gc_stats function to _remote_debugging (#148071) 2026-05-02 15:04:18 +00:00
Pablo Galindo Salgado 289fd2c97a gh-148178: Validate remote debug offset tables on load (#148187)
Treat the debug offset tables read from a target process as untrusted input
and validate them before the unwinder uses any reported sizes or offsets.

Add a shared validator in debug_offsets_validation.h and run it once when
_Py_DebugOffsets is loaded and once when AsyncioDebug is loaded. The checks
cover section sizes used for fixed local buffers and every offset that is
later dereferenced against a local buffer or local object view. This keeps
the bounds checks out of the sampling hot path while rejecting malformed
tables up front.
2026-04-13 22:22:23 +00:00
Karolina SurmaandVictor Stinner 1887a95f51 gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770)
Rename from _Py_INTERNAL_ABI_SLOT to _Py_ABI_SLOT
and define the macro using _PyABIInfo_DEFAULT.

Use the ABI slot in stdlib extension modules to enable running
a check of ABI version compatibility.

_tkinter, _tracemalloc and readline don't use the slots, hence they need
explicit handling.

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-24 17:47:55 +00:00
Pablo Galindo Salgado ae6adc9079 gh-146308: Fix error handling issues in _remote_debugging module (#146309) 2026-03-22 21:12:02 +00:00
flow a17301ab3d gh-135953: Properly obtain main thread identifier in Gecko Collector (#146045) 2026-03-22 18:53:00 +00:00
Taegyun Kim c2d3d6b0dd gh-144316: Fix missing exception in _remote_debugging with debug=False (#144442) 2026-02-26 21:14:34 +00:00
Bénédikt Tran 7726119651 gh-138122: fix AC warnings in Modules/_remote_debugging/module.c (#143218) 2025-12-27 12:57:03 +00:00
Pablo Galindo Salgado d3d4cf9432 gh-140739: Fix crashes from corrupted remote memory (#143190) 2025-12-26 16:06:48 +00:00
Pablo Galindo Salgado 81c8eb85e1 gh-138122: Add blocking mode for accurate stack traces in Tachyon (#142998) 2025-12-23 10:49:47 +00:00
Pablo Galindo Salgado 9e51301234 gh-138122: Allow tachyon to write and read binary output (#142730) 2025-12-22 23:57:20 +00:00
Pablo Galindo Salgado 6658e2cb07 gh-138122: Add --subprocesses flag to profile child processes in tachyon (#142636) 2025-12-15 12:11:40 +00:00
Pablo Galindo Salgado 6a0135a392 gh-138122: Add exception profiling mode to the sampling profiler (#142561) 2025-12-11 20:46:34 +00:00
Pablo Galindo Salgado 5b19c75b47 gh-138122: Make the tachyon profiler opcode-aware (#142394) 2025-12-11 03:41:47 +00:00
Pablo Galindo Salgado 572c780aa8 gh-138122: Implement frame caching in RemoteUnwinder to reduce memory reads (#142137)
This PR implements frame caching in the RemoteUnwinder class to significantly reduce memory reads when profiling remote processes with deep call stacks.

When cache_frames=True, the unwinder stores the frame chain from each sample and reuses unchanged portions in subsequent samples. Since most profiling samples capture similar call stacks (especially the parent frames), this optimization avoids repeatedly reading the same frame data from the target process.

The implementation adds a last_profiled_frame field to the thread state that tracks where the previous sample stopped. On the next sample, if the current frame chain reaches this marker, the cached frames from that point onward are reused instead of being re-read from remote memory.

The sampling profiler now enables frame caching by default.
2025-12-06 22:37:34 +00:00
Savannah OstrowskiandPablo Galindo Salgado 56a442d0d8 GH-141565: Add async code awareness to Tachyon (#141533)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2025-12-06 19:31:40 +00:00
Pablo Galindo Salgado d07d3a3c57 gh-138122: Split Modules/_remote_debugging_module.c into multiple files (#141934)
gh-1381228: Split Modules/_remote_debugging_module.c into multiple files
2025-11-25 12:51:24 +00:00