Skip to content

Commit 1dd8e14

Browse files
[3.15] gh-149584: Read remote stack chunks without the page cache (GH-160888) (GH-162211)
Read stack chunks directly in the sampling profiler. Avoid the page cache retry that can read a replacement chunk after the target process reuses the same address. (cherry picked from commit 355486e) Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
1 parent 5b9e3d0 commit 1dd8e14

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Read stack chunks directly in :mod:`profiling.sampling`, without the page
2+
cache. This removes a redundant retry on macOS that can read a replacement
3+
chunk after the target process reuses the same address.

‎Modules/_remote_debugging/frames.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ process_single_stack_chunk(
3636
return -1;
3737
}
3838

39-
if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, chunk_addr, current_size, this_chunk) < 0) {
39+
if (_Py_RemoteDebug_ReadRemoteMemory(&unwinder->handle, chunk_addr, current_size, this_chunk) < 0) {
4040
PyMem_RawFree(this_chunk);
4141
set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read stack chunk");
4242
return -1;
@@ -65,7 +65,7 @@ process_single_stack_chunk(
6565
}
6666
this_chunk = tmp;
6767

68-
if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, chunk_addr, actual_size, this_chunk) < 0) {
68+
if (_Py_RemoteDebug_ReadRemoteMemory(&unwinder->handle, chunk_addr, actual_size, this_chunk) < 0) {
6969
PyMem_RawFree(this_chunk);
7070
set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to reread stack chunk with correct size");
7171
return -1;

0 commit comments

Comments
 (0)