Fix GN thread sanitizer bug.

Tsan reported that Scope::GetValueWithScope was marking a value as "used"
on the same Scope from multiple threads. These sets were all to true so we
haven't noticed any stability problems, but we should not be trying to
write to scopes across threads.

What happens is that a template is created by BUILDCONFIG or a .gni file and
called from multiple BUILD.gn files in multiple threads. The scope stored by
the template was not marked const, so the derived scopes on each thread were
referencing this root closure as mutable and marking variables used in it.

This solution is to mark the Scope const. The derived scopes will reference
the parent scope as a const and no changes to the shared scope will occur.

Change-Id: I0a5026bb2f32b476babab63f479a5d377df410e8
Reviewed-on: https://chromium-review.googlesource.com/890230
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Brett Wilson <brettw@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#533408}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 9a22cda9d33378a3b579b329c1a3c1738d8973c2
1 file changed
tree: 5ac7e3699d6f7cccfb21078e5f02dfa4426e944a
  1. tools/