Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,16 @@ TaskInfo::unwind(EchionSampler& echion, FrameStack& stack, bool using_uvloop)
std::stack<PyObject*, std::vector<PyObject*>> coro_frames;

// Unwind the coro chain
size_t coro_chain_depth = 0;
for (auto py_coro = this->coro.get(); py_coro != NULL; py_coro = py_coro->await.get()) {
if (py_coro->frame != NULL)
coro_chain_depth++;
if (coro_chain_depth > MAX_RECURSION_DEPTH) {
break;
}

if (py_coro->frame != NULL) {
coro_frames.push(py_coro->frame);
}
}

// Total number of frames added to the Stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ ThreadInfo::unwind_tasks(EchionSampler& echion, PyThreadState* tstate)
auto stack_info = std::make_unique<StackInfo>(leaf_task.get().name, leaf_task.get().is_on_cpu);
auto& stack = stack_info->stack;

// Safety: prevent infinite loops from cycles in task chain maps
size_t task_chain_depth = 0;
for (auto current_task = leaf_task;;) {
if (++task_chain_depth > MAX_RECURSION_DEPTH) {
break;
}
auto& task = current_task.get();

auto task_stack_size = task.unwind(echion, stack, using_uvloop);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fixes:
- |
profiling: A bug where the Stack Profiler could loop infinitely (and allocate large amounts of memory,
leading to crashes) when sampling ``asyncio`` Tasks has been fixed.
Loading