[wasm] Fix DCHECK failure for custom platform implementation

Custom platform implementations which do not run all foreground tasks
before shutting down an isolate could trigger a DCHECK (see linked
issue).
This was introduced in https://crrev.com/c/2578980, but the bug does not
trigger in the default platform implementation, hence went unnoticed.

Since it's only a spurious DCHECK error without security implications, I
decided against a test with a custom platform implementation to
reproduce the bug.

R=ahaas@chromium.org

Bug: v8:11456
Change-Id: Ie01562af7bdffe23cad7172180f2bc19ea61dfda
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2697189
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72774}
This commit is contained in:
Clemens Backes 2021-02-16 13:40:56 +01:00 committed by Commit Bot
parent cf93071c91
commit d3ff488ac8

View File

@ -1008,10 +1008,14 @@ void WasmEngine::RemoveIsolate(Isolate* isolate) {
if (current_gc_info_) {
if (RemoveIsolateFromCurrentGC(isolate)) PotentiallyFinishCurrentGC();
}
if (auto* task = info->log_codes_task) task->Cancel();
for (auto& log_entry : info->code_to_log) {
WasmCode::DecrementRefCount(VectorOf(log_entry.second.code));
if (auto* task = info->log_codes_task) {
task->Cancel();
for (auto& log_entry : info->code_to_log) {
WasmCode::DecrementRefCount(VectorOf(log_entry.second.code));
}
info->code_to_log.clear();
}
DCHECK(info->code_to_log.empty());
isolate->counters()->wasm_throw_count()->AddSample(info->throw_count);
isolate->counters()->wasm_rethrow_count()->AddSample(info->rethrow_count);
isolate->counters()->wasm_catch_count()->AddSample(info->catch_count);