Skip to content

Commit cd41108

Browse files
backesV8 LUCI CQ
authored andcommitted
[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/+/2982339 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#75334}
1 parent d0aebc0 commit cd41108

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/tasks/operations-barrier.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace internal {
99

1010
OperationsBarrier::Token OperationsBarrier::TryLock() {
1111
base::MutexGuard guard(&mutex_);
12-
if (cancelled_) return Token(nullptr);
12+
if (cancelled_) return {};
1313
++operations_count_;
1414
return Token(this);
1515
}

src/tasks/operations-barrier.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ class V8_EXPORT_PRIVATE OperationsBarrier {
6969

7070
private:
7171
friend class OperationsBarrier;
72-
explicit Token(OperationsBarrier* outer) : outer_(outer) {}
72+
explicit Token(OperationsBarrier* outer) : outer_(outer) {
73+
DCHECK_NOT_NULL(outer_);
74+
}
7375
OperationsBarrier* outer_ = nullptr;
7476
};
7577

src/wasm/wasm-engine.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,8 +986,9 @@ void WasmEngine::DeleteCompileJobsOnIsolate(Isolate* isolate) {
986986

987987
OperationsBarrier::Token WasmEngine::StartWrapperCompilation(Isolate* isolate) {
988988
base::MutexGuard guard(&mutex_);
989-
DCHECK_EQ(1, isolates_.count(isolate));
990-
return isolates_[isolate]->wrapper_compilation_barrier_->TryLock();
989+
auto isolate_info_it = isolates_.find(isolate);
990+
if (isolate_info_it == isolates_.end()) return {};
991+
return isolate_info_it->second->wrapper_compilation_barrier_->TryLock();
991992
}
992993

993994
void WasmEngine::AddIsolate(Isolate* isolate) {

0 commit comments

Comments
 (0)