Commit a6e726f7 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Get v8_context_snapshot_generator to exit(1) instead of crash

Handling failures by crashing turns out to work poorly on Windows
because it is confusing (it looks like a bug rather than a build
failure) and because the process return code ends up being zero, so
ninja doesn't realize anything is wrong. This change fixes these
problems by detecting write failures and returning an error code.

This particular CHECK is being fixed because it is easy to accidentally
hit it simply by building Chrome while it is still running.

The new error checking is also better in that it verifies that all

Bug: 866656
Change-Id: I4303afaa898c85c72bd9d337fe8e19e239f17513
Reviewed-on: https://chromium-review.googlesource.com/1152159
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578770}
parent ddfb2b7e
...@@ -67,7 +67,13 @@ int main(int argc, char** argv) { ...@@ -67,7 +67,13 @@ int main(int argc, char** argv) {
base::FilePath file_path = base::FilePath file_path =
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath("output_file"); base::CommandLine::ForCurrentProcess()->GetSwitchValuePath("output_file");
CHECK(!file_path.empty()); CHECK(!file_path.empty());
CHECK_LT(0, base::WriteFile(file_path, blob.data, blob.raw_size)); int written = base::WriteFile(file_path, blob.data, blob.raw_size);
int error_code = 0;
if (written != blob.raw_size) {
fprintf(stderr, "Error: WriteFile of %d snapshot bytes returned %d.\n",
blob.raw_size, written);
error_code = 1;
}
delete[] blob.data; delete[] blob.data;
...@@ -75,5 +81,5 @@ int main(int argc, char** argv) { ...@@ -75,5 +81,5 @@ int main(int argc, char** argv) {
// manage lifetime of v8::Isolate, gin::IsolateHolder, and // manage lifetime of v8::Isolate, gin::IsolateHolder, and
// blink::V8PerIsolateData. Now we complete all works at this point, and can // blink::V8PerIsolateData. Now we complete all works at this point, and can
// exit without releasing all those instances correctly. // exit without releasing all those instances correctly.
_exit(0); _exit(error_code);
} }
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