Skip to content
Commit fa69d270 authored by Anton Bikineev's avatar Anton Bikineev Committed by Chromium LUCI CQ
Browse files

*Scan: Fix reentrancy in the scheduler

Deadlock scenario:
1) Thread A calls free();
2) PCScanSchedulingBackend::LimitReached() is called, the lock is
acquired and the current_limit is updated to the hard_limit;
3) In the meantime, free() with a giant object is called by another
thread B and the hard limit is reached;
4) The thread A calls the scheduling callback, which schedules a delayed
task;
5) std::condvar::notify_one() is called, which calls free() and reenters
PCScanSchedulingBackend::LimitReached(), trying to recursively acquire
the mutex, first acquired on step 2).

The current CL fixes this by hoisting the callback out of the critical
section.

Bug: 11297512
Change-Id: I10e2a1f83741a6b53a5c48d7632b655fb12de91a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3116252


Auto-Submit: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#914754}
parent 21ab2cdf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment