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

[d8] Check that we never block in predictable mode

Since there is only a single thread in predictable mode, we should never
wait for more work. That would be an immediate deadlock.
This CL adds code to never wait, and instead checks after processing all
messages that we would not need to wait (i.e. that all work was
completed). This turns deadlocks into FATAL errors.

R=ahaas@chromium.org

Bug: v8:11848
Change-Id: If61305d634803fc43678238dc6e9d3a2f35793c8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2940886Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74966}
parent 915510e2
......@@ -4106,7 +4106,7 @@ void Worker::ExecuteInThread() {
NewStringType::kInternalized));
Local<Value> onmessage;
if (maybe_onmessage.ToLocal(&onmessage) && onmessage->IsFunction()) {
// Now wait for messages
// Now wait for messages.
ProcessMessages();
}
}
......@@ -4573,6 +4573,17 @@ bool Shell::CompleteMessageLoop(Isolate* isolate) {
return should_wait ? platform::MessageLoopBehavior::kWaitForWork
: platform::MessageLoopBehavior::kDoNotWait;
};
if (i::FLAG_verify_predictable) {
bool ran_tasks = ProcessMessages(
isolate, [] { return platform::MessageLoopBehavior::kDoNotWait; });
if (get_waiting_behaviour() ==
platform::MessageLoopBehavior::kWaitForWork) {
FATAL(
"There is outstanding work after executing all tasks in predictable "
"mode -- this would deadlock.");
}
return ran_tasks;
}
return ProcessMessages(isolate, get_waiting_behaviour);
}
......
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