[inspector][test] Exit properly on internal errors
Calling {Exit} does not stop execution in the current thread (or process), it just tells the two task runners to stop. Hence following code would still be executed. This CL replaces the calls to {Exit} to {FATAL} for internal errors where we want to stop immediately. R=szuend@chromium.org Bug: chromium:1142437 Change-Id: I70c1c39da28a3cd040214d46eddf61f05a12bce7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2519568 Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#70984}
This commit is contained in:
parent
77a77f050a
commit
ff2993bb45
@ -49,12 +49,6 @@ void Terminate() {
|
||||
task_runners.swap(empty);
|
||||
}
|
||||
|
||||
void Exit() {
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
Terminate();
|
||||
}
|
||||
|
||||
class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
public:
|
||||
~UtilsExtension() override = default;
|
||||
@ -151,20 +145,22 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
int n =
|
||||
static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout));
|
||||
if (n != str.length()) {
|
||||
printf("Error in fwrite\n");
|
||||
Quit(args);
|
||||
FATAL("Error in fwrite\n");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { Exit(); }
|
||||
static void Quit(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
Terminate();
|
||||
}
|
||||
|
||||
static void Setlocale(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsString()) {
|
||||
fprintf(stderr, "Internal error: setlocale get one string argument.");
|
||||
Exit();
|
||||
FATAL("Internal error: setlocale get one string argument.");
|
||||
}
|
||||
|
||||
v8::String::Utf8Value str(args.GetIsolate(), args[1]);
|
||||
@ -186,8 +182,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
|
||||
static void Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsString()) {
|
||||
fprintf(stderr, "Internal error: read gets one string argument.");
|
||||
Exit();
|
||||
FATAL("Internal error: read gets one string argument.");
|
||||
}
|
||||
std::string chars;
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
@ -198,8 +193,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
|
||||
static void Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsString()) {
|
||||
fprintf(stderr, "Internal error: load gets one string argument.");
|
||||
Exit();
|
||||
FATAL("Internal error: load gets one string argument.");
|
||||
}
|
||||
std::string chars;
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
@ -216,11 +210,9 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
if (args.Length() != 6 || !args[0]->IsInt32() || !args[1]->IsString() ||
|
||||
!args[2]->IsString() || !args[3]->IsInt32() || !args[4]->IsInt32() ||
|
||||
!args[5]->IsBoolean()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: compileAndRunWithOrigin(context_group_id, "
|
||||
"source, name, line, "
|
||||
"column, is_module).");
|
||||
Exit();
|
||||
FATAL(
|
||||
"Internal error: compileAndRunWithOrigin(context_group_id, source, "
|
||||
"name, line, column, is_module).");
|
||||
}
|
||||
|
||||
backend_runner_->Append(new ExecuteStringTask(
|
||||
@ -233,8 +225,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void SetCurrentTimeMSForTest(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsNumber()) {
|
||||
fprintf(stderr, "Internal error: setCurrentTimeMSForTest(time).");
|
||||
Exit();
|
||||
FATAL("Internal error: setCurrentTimeMSForTest(time).");
|
||||
}
|
||||
backend_runner_->data()->SetCurrentTimeMS(
|
||||
args[0].As<v8::Number>()->Value());
|
||||
@ -243,8 +234,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void SetMemoryInfoForTest(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1) {
|
||||
fprintf(stderr, "Internal error: setMemoryInfoForTest(value).");
|
||||
Exit();
|
||||
FATAL("Internal error: setMemoryInfoForTest(value).");
|
||||
}
|
||||
backend_runner_->data()->SetMemoryInfo(args[0]);
|
||||
}
|
||||
@ -253,10 +243,9 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 3 || !args[0]->IsInt32() || !args[1]->IsString() ||
|
||||
!args[2]->IsString()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: schedulePauseOnNextStatement(context_group_id, "
|
||||
"'reason', 'details').");
|
||||
Exit();
|
||||
FATAL(
|
||||
"Internal error: schedulePauseOnNextStatement(context_group_id, "
|
||||
"'reason', 'details').");
|
||||
}
|
||||
std::vector<uint16_t> reason =
|
||||
ToVector(args.GetIsolate(), args[1].As<v8::String>());
|
||||
@ -275,9 +264,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void CancelPauseOnNextStatement(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsInt32()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: cancelPauseOnNextStatement(context_group_id).");
|
||||
Exit();
|
||||
FATAL("Internal error: cancelPauseOnNextStatement(context_group_id).");
|
||||
}
|
||||
int context_group_id = args[0].As<v8::Int32>()->Value();
|
||||
RunSyncTask(backend_runner_, [&context_group_id](IsolateData* data) {
|
||||
@ -288,8 +275,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void SetLogConsoleApiMessageCalls(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsBoolean()) {
|
||||
fprintf(stderr, "Internal error: setLogConsoleApiMessageCalls(bool).");
|
||||
Exit();
|
||||
FATAL("Internal error: setLogConsoleApiMessageCalls(bool).");
|
||||
}
|
||||
backend_runner_->data()->SetLogConsoleApiMessageCalls(
|
||||
args[0].As<v8::Boolean>()->Value());
|
||||
@ -298,9 +284,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void SetLogMaxAsyncCallStackDepthChanged(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsBoolean()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: setLogMaxAsyncCallStackDepthChanged(bool).");
|
||||
Exit();
|
||||
FATAL("Internal error: setLogMaxAsyncCallStackDepthChanged(bool).");
|
||||
}
|
||||
backend_runner_->data()->SetLogMaxAsyncCallStackDepthChanged(
|
||||
args[0].As<v8::Boolean>()->Value());
|
||||
@ -309,8 +293,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void SetAdditionalConsoleApi(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsString()) {
|
||||
fprintf(stderr, "Internal error: SetAdditionalConsoleApi(string).");
|
||||
Exit();
|
||||
FATAL("Internal error: SetAdditionalConsoleApi(string).");
|
||||
}
|
||||
std::vector<uint16_t> script =
|
||||
ToVector(args.GetIsolate(), args[0].As<v8::String>());
|
||||
@ -323,8 +306,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void CreateContextGroup(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 0) {
|
||||
fprintf(stderr, "Internal error: createContextGroup().");
|
||||
Exit();
|
||||
FATAL("Internal error: createContextGroup().");
|
||||
}
|
||||
int context_group_id = 0;
|
||||
RunSyncTask(backend_runner_, [&context_group_id](IsolateData* data) {
|
||||
@ -336,8 +318,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
|
||||
static void CreateContext(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 2) {
|
||||
fprintf(stderr, "Internal error: createContext(context, name).");
|
||||
Exit();
|
||||
FATAL("Internal error: createContext(context, name).");
|
||||
}
|
||||
int context_group_id = args[0].As<v8::Int32>()->Value();
|
||||
std::vector<uint16_t> name =
|
||||
@ -352,8 +333,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void ResetContextGroup(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsInt32()) {
|
||||
fprintf(stderr, "Internal error: resetContextGroup(context_group_id).");
|
||||
Exit();
|
||||
FATAL("Internal error: resetContextGroup(context_group_id).");
|
||||
}
|
||||
int context_group_id = args[0].As<v8::Int32>()->Value();
|
||||
RunSyncTask(backend_runner_, [&context_group_id](IsolateData* data) {
|
||||
@ -364,10 +344,9 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void ConnectSession(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 3 || !args[0]->IsInt32() || !args[1]->IsString() ||
|
||||
!args[2]->IsFunction()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: connectionSession(context_group_id, state, "
|
||||
"dispatch).");
|
||||
Exit();
|
||||
FATAL(
|
||||
"Internal error: connectionSession(context_group_id, state, "
|
||||
"dispatch).");
|
||||
}
|
||||
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
|
||||
FrontendChannelImpl* channel = new FrontendChannelImpl(
|
||||
@ -394,8 +373,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void DisconnectSession(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsInt32()) {
|
||||
fprintf(stderr, "Internal error: disconnectionSession(session_id).");
|
||||
Exit();
|
||||
FATAL("Internal error: disconnectionSession(session_id).");
|
||||
}
|
||||
int session_id = args[0].As<v8::Int32>()->Value();
|
||||
std::vector<uint8_t> state;
|
||||
@ -409,9 +387,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||
static void SendMessageToBackend(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 2 || !args[0]->IsInt32() || !args[1]->IsString()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: sendMessageToBackend(session_id, message).");
|
||||
Exit();
|
||||
FATAL("Internal error: sendMessageToBackend(session_id, message).");
|
||||
}
|
||||
backend_runner_->Append(new SendMessageToBackendTask(
|
||||
args[0].As<v8::Int32>()->Value(),
|
||||
@ -524,9 +500,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void AddInspectedObject(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 2 || !args[0]->IsInt32()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: addInspectedObject(session_id, object).");
|
||||
Exit();
|
||||
FATAL("Internal error: addInspectedObject(session_id, object).");
|
||||
}
|
||||
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
|
||||
IsolateData* data = IsolateData::FromContext(context);
|
||||
@ -536,8 +510,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void SetMaxAsyncTaskStacks(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsInt32()) {
|
||||
fprintf(stderr, "Internal error: setMaxAsyncTaskStacks(max).");
|
||||
Exit();
|
||||
FATAL("Internal error: setMaxAsyncTaskStacks(max).");
|
||||
}
|
||||
IsolateData::FromContext(args.GetIsolate()->GetCurrentContext())
|
||||
->SetMaxAsyncTaskStacksForTest(args[0].As<v8::Int32>()->Value());
|
||||
@ -546,8 +519,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void DumpAsyncTaskStacksStateForTest(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 0) {
|
||||
fprintf(stderr, "Internal error: dumpAsyncTaskStacksStateForTest().");
|
||||
Exit();
|
||||
FATAL("Internal error: dumpAsyncTaskStacksStateForTest().");
|
||||
}
|
||||
IsolateData::FromContext(args.GetIsolate()->GetCurrentContext())
|
||||
->DumpAsyncTaskStacksStateForTest();
|
||||
@ -555,8 +527,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
|
||||
static void BreakProgram(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) {
|
||||
fprintf(stderr, "Internal error: breakProgram('reason', 'details').");
|
||||
Exit();
|
||||
FATAL("Internal error: breakProgram('reason', 'details').");
|
||||
}
|
||||
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
|
||||
IsolateData* data = IsolateData::FromContext(context);
|
||||
@ -573,8 +544,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void CreateObjectWithStrictCheck(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 0) {
|
||||
fprintf(stderr, "Internal error: createObjectWithStrictCheck().");
|
||||
Exit();
|
||||
FATAL("Internal error: createObjectWithStrictCheck().");
|
||||
}
|
||||
v8::Local<v8::ObjectTemplate> templ =
|
||||
v8::ObjectTemplate::New(args.GetIsolate());
|
||||
@ -588,9 +558,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 3 || !args[0]->IsFunction() || !args[1]->IsString() ||
|
||||
!args[2]->IsString()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: callWithScheduledBreak('reason', 'details').");
|
||||
Exit();
|
||||
FATAL("Internal error: callWithScheduledBreak('reason', 'details').");
|
||||
}
|
||||
std::vector<uint16_t> reason =
|
||||
ToVector(args.GetIsolate(), args[1].As<v8::String>());
|
||||
@ -612,8 +580,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void AllowAccessorFormatting(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsObject()) {
|
||||
fprintf(stderr, "Internal error: allowAccessorFormatting('object').");
|
||||
Exit();
|
||||
FATAL("Internal error: allowAccessorFormatting('object').");
|
||||
}
|
||||
v8::Local<v8::Object> object = args[0].As<v8::Object>();
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
@ -628,8 +595,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void MarkObjectAsNotInspectable(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsObject()) {
|
||||
fprintf(stderr, "Internal error: markObjectAsNotInspectable(object).");
|
||||
Exit();
|
||||
FATAL("Internal error: markObjectAsNotInspectable(object).");
|
||||
}
|
||||
v8::Local<v8::Object> object = args[0].As<v8::Object>();
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
@ -644,10 +610,9 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void CreateObjectWithAccessor(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsBoolean()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: createObjectWithAccessor('accessor name', "
|
||||
"hasSetter)\n");
|
||||
Exit();
|
||||
FATAL(
|
||||
"Internal error: createObjectWithAccessor('accessor name', "
|
||||
"hasSetter)\n");
|
||||
}
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
|
||||
@ -677,9 +642,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void StoreCurrentStackTrace(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsString()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: storeCurrentStackTrace('description')\n");
|
||||
Exit();
|
||||
FATAL("Internal error: storeCurrentStackTrace('description')\n");
|
||||
}
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
@ -700,8 +663,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void ExternalAsyncTaskStarted(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsArrayBuffer()) {
|
||||
fprintf(stderr, "Internal error: externalAsyncTaskStarted(id)\n");
|
||||
Exit();
|
||||
FATAL("Internal error: externalAsyncTaskStarted(id)\n");
|
||||
}
|
||||
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
|
||||
IsolateData* data = IsolateData::FromContext(context);
|
||||
@ -714,8 +676,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void ExternalAsyncTaskFinished(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsArrayBuffer()) {
|
||||
fprintf(stderr, "Internal error: externalAsyncTaskFinished(id)\n");
|
||||
Exit();
|
||||
FATAL("Internal error: externalAsyncTaskFinished(id)\n");
|
||||
}
|
||||
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
|
||||
IsolateData* data = IsolateData::FromContext(context);
|
||||
@ -729,10 +690,9 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 3 || !args[0]->IsFunction() || !args[1]->IsString() ||
|
||||
!args[2]->IsBoolean()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: scheduleWithAsyncStack(function, "
|
||||
"'task-name', with_empty_stack).");
|
||||
Exit();
|
||||
FATAL(
|
||||
"Internal error: scheduleWithAsyncStack(function, 'task-name', "
|
||||
"with_empty_stack).");
|
||||
}
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
@ -754,9 +714,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void SetAllowCodeGenerationFromStrings(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsBoolean()) {
|
||||
fprintf(stderr,
|
||||
"Internal error: setAllowCodeGenerationFromStrings(allow).");
|
||||
Exit();
|
||||
FATAL("Internal error: setAllowCodeGenerationFromStrings(allow).");
|
||||
}
|
||||
args.GetIsolate()->GetCurrentContext()->AllowCodeGenerationFromStrings(
|
||||
args[0].As<v8::Boolean>()->Value());
|
||||
@ -765,8 +723,7 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
static void SetResourceNamePrefix(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsString()) {
|
||||
fprintf(stderr, "Internal error: setResourceNamePrefix('prefix').");
|
||||
Exit();
|
||||
FATAL("Internal error: setResourceNamePrefix('prefix').");
|
||||
}
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
@ -831,9 +788,7 @@ int InspectorTestMain(int argc, char* argv[]) {
|
||||
bool exists = false;
|
||||
std::string chars = ReadFile(argv[i], &exists, true);
|
||||
if (!exists) {
|
||||
fprintf(stderr, "Internal error: script file doesn't exists: %s\n",
|
||||
argv[i]);
|
||||
Exit();
|
||||
FATAL("Internal error: script file doesn't exists: %s\n", argv[i]);
|
||||
}
|
||||
frontend_runner.Append(
|
||||
new ExecuteStringTask(chars, frontend_context_group_id));
|
||||
|
Loading…
Reference in New Issue
Block a user