Commit 97baa137 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

Make sure doCallback() doesn't write into Executor if it's nullptr

Summary: SemiFuture implementation assumes that it's always safe to read Executor (if Executor is DeferredExecutor - then SemiFuture can never be completed until via is called, otherwise Executor is nullptr and we should never overwrite it). doCallback() however was unconditionally overwritting Executor, which resulted in TSAN reports.

Reviewed By: yfeldblum

Differential Revision: D14063047

fbshipit-source-id: 7553c8a2d0cbda05ad07b87297a334a69ee77f9c
parent 9d8a3f73
......@@ -569,10 +569,11 @@ class Core final {
// May be called at most once.
void doCallback() {
DCHECK(state_ == State::Done);
auto x = exchange(executor_, Executor::KeepAlive<>());
int8_t priority = priority_;
if (x) {
if (executor_) {
auto x = exchange(executor_, Executor::KeepAlive<>());
int8_t priority = priority_;
exception_wrapper ew;
// We need to reset `callback_` after it was executed (which can happen
// through the executor or, if `Executor::add` throws, below). The
......
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