New issue
Advanced search Search tips

Issue 866656 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jul 27
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

v8_context_snapshot_generator.cc should return a failure code for write failures instead of using CHECK

Project Member Reported by brucedaw...@chromium.org, Jul 23

Issue description

CHECK should be used for logic errors, not genuine runtime errors. This is true for build tools as well as for Chrome. In the worst case the use of a CHECK can, apparently, cause a build to succeed when it should fail, as shown below:

> ninja chrome -j 960 -l 48
[1 processes, 1/1 @ 0.3/s : 3.337s ] Regenerating ninja files
[960 processes, 2623/22981 @ 61.0/s : 42.994s ] CXX obj/media/filters/filters/ffmpeg_video_decoder.obj
wineserver: could not save registry branch to user.reg : Device or resource busy
[1 processes, 22961/22971 @ 54.3/s : 422.495s ] ACTION //tools/v8_context_snapshot:generate_v8_context_snapshot(//build/toolchain/win:win_clang_x64)
[0723/145133.979:FATAL:v8_context_snapshot_generator.cc(70)] Check failed: 0 < base::WriteFile(file_path, blob.data, blob.raw_size) (0 vs. -1)
Backtrace:
        base::debug::StackTrace::StackTrace [0x00007FF6DB5C5404+36] (C:\src\chromium3\src\base\debug\stack_trace_win.cc:286)
        logging::LogMessage::~LogMessage [0x00007FF6DB445ED5+101] (C:\src\chromium3\src\base\logging.cc:593)
        main [0x00007FF6DA711155+341] (C:\src\chromium3\src\tools\v8_context_snapshot\v8_context_snapshot_generator.cc:72)
        __scrt_common_main_seh [0x00007FF6DCB8EDE8+268] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283)
        BaseThreadInitThunk [0x00007FFFA2CE1FE4+20]
        RtlUserThreadStart [0x00007FFFA3D7CB31+33]

[1 processes, 22969/22969 @ 50.0/s : 459.503s ] STAMP obj/chrome/chrome.stamp

The CHECK failed, presumably due to having a test process open in a debugger, thus locking the file. A just-in-time debugger dialog popped up and a chose a Visual Studio instance to debug the crash. Already this is misleading because a crash implies a tool bug when in fact the problem was just a locked file.

After examining the failure in the debugger I closed the debugger and I *guess* the process exited with an error code of zero, meaning that the build continued, despite not having written the file!

 
Status: Started (was: Assigned)
Repro:

> ninja chrome
> chrome (leave chrome running)
> touch ..\..\tools\v8_context_snapshot\v8_context_snapshot_generator.cc
> ninja chrome (cancel just-in-time debugger dialog when it appears)
[0726/134634.258:FATAL:v8_context_snapshot_generator.cc(70)] Check failed: 0 < base::WriteFile(file_path, blob.data, blob.raw_size) (0 vs. -1)
> ninja chrome
ninja: no work to do.

So, easy repro that demonstrates two problems:
1) I don't want build failures reported through crashes
2) The build is marked as being successful when it is not

Fix is out for review.

Project Member

Comment 2 by bugdroid1@chromium.org, Jul 27

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a6e726f7d8e52afd627f036eba4b1798d9dbe278

commit a6e726f7d8e52afd627f036eba4b1798d9dbe278
Author: Bruce Dawson <brucedawson@chromium.org>
Date: Fri Jul 27 20:55:24 2018

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: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578770}
[modify] https://crrev.com/a6e726f7d8e52afd627f036eba4b1798d9dbe278/tools/v8_context_snapshot/v8_context_snapshot_generator.cc

Status: Fixed (was: Started)

Sign in to add a comment