Skip to content

Commit

Permalink
Fix 'gn gen --check' hanging indefinitely
Browse files Browse the repository at this point in the history
r531270 refactored HeaderChecker to use an atomic counter to track the number of
header-checking tasks.  The main thread waits on the task count becoming zero,
and the task counter is decremented whenever a task completes.  However, the
main thread didn't increment the task counter when it created a task, so the
counter would count into negative values and never reach zero, hanging gn
indefinitely.  The fix is to increment the counter when posting a task.

R=dpranke
CC=fdoray

Change-Id: Id55f943cf0e2af3e9e5af5f3dddf8a7b7671eaac
Reviewed-on: https://chromium-review.googlesource.com/889930
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532684}
  • Loading branch information
tanderson-google authored and Commit Bot committed Jan 30, 2018
1 parent acd86d9 commit 7c742b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/gn/header_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void HeaderChecker::RunCheckOverFiles(const FileMap& files, bool force_check) {

for (const auto& vect_i : file.second) {
if (vect_i.target->check_includes()) {
task_count_.Increment();
base::PostTaskWithTraits(FROM_HERE, {base::MayBlock()},
base::BindOnce(&HeaderChecker::DoWork, this,
vect_i.target, file.first));
Expand Down Expand Up @@ -581,4 +582,3 @@ Err HeaderChecker::MakeUnreachableError(
return Err(CreatePersistentRange(source_file, range),
"Include not allowed.", msg);
}

0 comments on commit 7c742b6

Please sign in to comment.