Commit 8ee3ba54 authored by Sarang Masti's avatar Sarang Masti Committed by Nicholas Ormrod

Fix use-after-free in futexWaitUntilImpl

Summary: Handle wake-ups correctly in futexWaitUntilImpl.

Test Plan:
-- ran all folly unit tests
-- ran TimeoutWorkQueue test under tao/queues

Reviewed By: ngbronson@fb.com, meyering@fb.com

FB internal diff: D1406845

Tasks: 4494871
parent 0498579d
...@@ -278,8 +278,10 @@ FutexResult futexWaitUntilImpl(Futex<DeterministicAtomic>* futex, ...@@ -278,8 +278,10 @@ FutexResult futexWaitUntilImpl(Futex<DeterministicAtomic>* futex,
futexLock.lock(); futexLock.lock();
// Simulate spurious wake-ups, timeouts each time with // Simulate spurious wake-ups, timeouts each time with
// a 10% probability // a 10% probability if we haven't been woken up already
if (DeterministicSchedule::getRandNumber(100) < 10) { if (!rv && DeterministicSchedule::getRandNumber(100) < 10) {
assert(futexQueues.count(futex) != 0 &&
&futexQueues[futex] == &queue);
queue.erase(ours); queue.erase(ours);
if (queue.empty()) { if (queue.empty()) {
futexQueues.erase(futex); futexQueues.erase(futex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment