Skip to content

Commit 6936150

Browse files
fmeumcopybara-github
authored andcommitted
Fix data race in IndexRegistry#getBazelRegistryJson
Should fix the following crash observed in the wild: ``` FATAL: bazel crashed due to an internal error. Printing stack trace: java.lang.RuntimeException: Unrecoverable error while evaluating node 'RepoSpecKey{[email protected], registryUrl=https://bcr.bazel.build/}' (requested by nodes 'com.google.devtools.build.lib.bazel.bzlmod.BazelModuleResolutionValue$$Lambda/0x00000008005fd220@38aba3ca') at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:550) at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:414) at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(Unknown Source) at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) Caused by: java.lang.NullPointerException: Cannot invoke "com.google.devtools.build.lib.events.StoredEventHandler.replayOn(com.google.devtools.build.lib.events.ExtendedEventHandler)" because "this.bazelRegistryJsonEvents" is null at com.google.devtools.build.lib.bazel.bzlmod.IndexRegistry.getBazelRegistryJson(IndexRegistry.java:336) at com.google.devtools.build.lib.bazel.bzlmod.IndexRegistry.getRepoSpec(IndexRegistry.java:295) at com.google.devtools.build.lib.bazel.bzlmod.RepoSpecFunction.compute(RepoSpecFunction.java:52) at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:461) ... 7 more ``` Closes #22639. PiperOrigin-RevId: 640572972 Change-Id: Id24ce3476df55fa75d6f3291e100b1037f0793f4
1 parent 98c6c49 commit 6936150

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/com/google/devtools/build/lib/bazel/bzlmod/IndexRegistry.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,10 @@ private String getSourceJsonUrl(ModuleKey key) {
321321

322322
private Optional<BazelRegistryJson> getBazelRegistryJson(ExtendedEventHandler eventHandler)
323323
throws IOException, InterruptedException {
324-
if (bazelRegistryJson == null) {
324+
if (bazelRegistryJson == null || bazelRegistryJsonEvents == null) {
325325
synchronized (this) {
326-
if (bazelRegistryJson == null) {
326+
if (bazelRegistryJson == null || bazelRegistryJsonEvents == null) {
327+
Preconditions.checkState(bazelRegistryJson == null && bazelRegistryJsonEvents == null);
327328
var storedEventHandler = new StoredEventHandler();
328329
bazelRegistryJson =
329330
grabJson(

0 commit comments

Comments
 (0)