Commit 83a2f390 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[inspector][fuzzer] Suppress messages about uncaught exceptions

The fuzzer is expected to generate a lot of syntax and runtime errors,
and the respective messages just flood the fuzzer output. By always
putting a {TryCatch} scope around the execution, we prevent those
messages from being printed.
At the same time, inspector tests need to properly propagate uncaught
exceptions in the backend to the inspector, and fail on uncaught
exceptions in the frontend.

This CL allows for all these behaviours by extending the
{CatchExceptions} enum and the {TryCatch} logic in the task runner.

Drive-by: Use {base::OS::ExitProcess} instead of the explicit
{fflush} and {_exit}.

R=szuend@chromium.org

Bug: chromium:1142437
Change-Id: Ic2cb3b0de2399d25bd8c53090575308cb0e09ab0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2529135
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71152}
parent 15c9ff07
......@@ -568,8 +568,8 @@ void FuzzInspector(const uint8_t* data, size_t size) {
IsolateData::SetupGlobalTasks frontend_extensions;
frontend_extensions.emplace_back(new UtilsExtension());
TaskRunner frontend_runner(std::move(frontend_extensions),
kDontCatchExceptions, &ready_semaphore, nullptr,
kNoInspector);
kSuppressUncaughtExceptions, &ready_semaphore,
nullptr, kNoInspector);
ready_semaphore.Wait();
int frontend_context_group_id = 0;
......@@ -581,8 +581,9 @@ void FuzzInspector(const uint8_t* data, size_t size) {
IsolateData::SetupGlobalTasks backend_extensions;
backend_extensions.emplace_back(new SetTimeoutExtension());
backend_extensions.emplace_back(new InspectorExtension());
TaskRunner backend_runner(std::move(backend_extensions), kDontCatchExceptions,
&ready_semaphore, nullptr, kWithInspector);
TaskRunner backend_runner(std::move(backend_extensions),
kSuppressUncaughtExceptions, &ready_semaphore,
nullptr, kWithInspector);
ready_semaphore.Wait();
UtilsExtension::set_backend_task_runner(&backend_runner);
......
......@@ -753,9 +753,10 @@ int InspectorTestMain(int argc, char* argv[]) {
{
IsolateData::SetupGlobalTasks frontend_extensions;
frontend_extensions.emplace_back(new UtilsExtension());
TaskRunner frontend_runner(
std::move(frontend_extensions), kDoCatchExceptions, &ready_semaphore,
startup_data.data ? &startup_data : nullptr, kNoInspector);
TaskRunner frontend_runner(std::move(frontend_extensions),
kFailOnUncaughtExceptions, &ready_semaphore,
startup_data.data ? &startup_data : nullptr,
kNoInspector);
ready_semaphore.Wait();
int frontend_context_group_id = 0;
......@@ -768,8 +769,9 @@ int InspectorTestMain(int argc, char* argv[]) {
backend_extensions.emplace_back(new SetTimeoutExtension());
backend_extensions.emplace_back(new InspectorExtension());
TaskRunner backend_runner(
std::move(backend_extensions), kDontCatchExceptions, &ready_semaphore,
startup_data.data ? &startup_data : nullptr, kWithInspector);
std::move(backend_extensions), kStandardPropagateUncaughtExceptions,
&ready_semaphore, startup_data.data ? &startup_data : nullptr,
kWithInspector);
ready_semaphore.Wait();
UtilsExtension::set_backend_task_runner(&backend_runner);
......
......@@ -68,18 +68,17 @@ void TaskRunner::RunMessageLoop(bool only_protocol) {
std::unique_ptr<TaskRunner::Task> task = GetNext(only_protocol);
if (!task) return;
v8::Isolate::Scope isolate_scope(isolate());
if (catch_exceptions_) {
v8::TryCatch try_catch(isolate());
task->Run(data_.get());
if (try_catch.HasCaught()) {
ReportUncaughtException(isolate(), try_catch);
fflush(stdout);
fflush(stderr);
_exit(0);
}
} else {
task->Run(data_.get());
v8::TryCatch try_catch(isolate());
if (catch_exceptions_ == kStandardPropagateUncaughtExceptions) {
try_catch.SetVerbose(true);
}
task->Run(data_.get());
if (catch_exceptions_ == kFailOnUncaughtExceptions &&
try_catch.HasCaught()) {
ReportUncaughtException(isolate(), try_catch);
base::OS::ExitProcess(0);
}
try_catch.Reset();
task.reset();
// Also pump isolate's foreground task queue to ensure progress.
// This can be removed once https://crbug.com/v8/10747 is fixed.
......
......@@ -20,9 +20,10 @@
namespace v8 {
namespace internal {
enum CatchExceptions : bool {
kDoCatchExceptions = true,
kDontCatchExceptions = false
enum CatchExceptions {
kFailOnUncaughtExceptions,
kStandardPropagateUncaughtExceptions,
kSuppressUncaughtExceptions
};
class TaskRunner : public v8::base::Thread {
......
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