Commit cd41108d authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Fix race on isolate shutdown

If we were unlucky and start wrapper compilation exactly after the
isolate started shutting down, we would not have an isolate info any
more in the isolate and would access a nullptr.
This CL fixes that by just returning an invalid operations barrier token
in that case.

R=ahaas@chromium.org

Bug: v8:11878
Change-Id: I6dcb28a21debb12ba812f705cd5c6387c76eda09
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2982339Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75334}
parent d0aebc06
......@@ -9,7 +9,7 @@ namespace internal {
OperationsBarrier::Token OperationsBarrier::TryLock() {
base::MutexGuard guard(&mutex_);
if (cancelled_) return Token(nullptr);
if (cancelled_) return {};
++operations_count_;
return Token(this);
}
......
......@@ -69,7 +69,9 @@ class V8_EXPORT_PRIVATE OperationsBarrier {
private:
friend class OperationsBarrier;
explicit Token(OperationsBarrier* outer) : outer_(outer) {}
explicit Token(OperationsBarrier* outer) : outer_(outer) {
DCHECK_NOT_NULL(outer_);
}
OperationsBarrier* outer_ = nullptr;
};
......
......@@ -986,8 +986,9 @@ void WasmEngine::DeleteCompileJobsOnIsolate(Isolate* isolate) {
OperationsBarrier::Token WasmEngine::StartWrapperCompilation(Isolate* isolate) {
base::MutexGuard guard(&mutex_);
DCHECK_EQ(1, isolates_.count(isolate));
return isolates_[isolate]->wrapper_compilation_barrier_->TryLock();
auto isolate_info_it = isolates_.find(isolate);
if (isolate_info_it == isolates_.end()) return {};
return isolate_info_it->second->wrapper_compilation_barrier_->TryLock();
}
void WasmEngine::AddIsolate(Isolate* isolate) {
......
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