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