Fix crash when environ contains duplicate entries#19245
Closed
fmeum wants to merge 2 commits intobazelbuild:masterfrom
Closed
Fix crash when environ contains duplicate entries#19245fmeum wants to merge 2 commits intobazelbuild:masterfrom
environ contains duplicate entries#19245fmeum wants to merge 2 commits intobazelbuild:masterfrom
Conversation
The values of the internal `$environ` attribute of repository rules is now deduplicated. `ActionEnvironmentFunction#getEnvironmentView`'s signature is updated to receive a `Set` to ensure deduplication for all callers. Previously, a repository rule with duplicate values in `environ` could crash with: ``` FATAL: bazel crashed due to an internal error. Printing stack trace: java.lang.RuntimeException: Unrecoverable error while evaluating node 'REPOSITORY_DIRECTORY:@foo' (requested by nodes 'IGNORED_PACKAGE_PREFIXES:@foo') at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:633) at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:365) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.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.IllegalArgumentException: Multiple entries with same key: FOO=bar and FOO=bar at com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:377) at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:371) at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:241) at com.google.common.collect.RegularImmutableMap.fromEntryArrayCheckingBucketOverflow(RegularImmutableMap.java:132) at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:94) at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:573) at com.google.common.collect.ImmutableMap$Builder.buildOrThrow(ImmutableMap.java:601) at com.google.devtools.build.lib.skyframe.ActionEnvironmentFunction.getEnvironmentView(ActionEnvironmentFunction.java:105) at com.google.devtools.build.lib.rules.repository.RepositoryFunction.getEnvVarValues(RepositoryFunction.java:305) ... ```
Wyverald
reviewed
Aug 14, 2023
...ain/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java
Outdated
Show resolved
Hide resolved
Contributor
|
This probably warrants a 6.3.3 |
Wyverald
approved these changes
Aug 14, 2023
Member
|
I think I would've just changed that one re 6.3.3: I'd personally like to wait to see if there's more bug reports first. I'd say this is a low-probability mid-severity regression; if nobody encounters this, I'd rather not spend the resources on a patch release. |
Collaborator
Author
|
@Wyverald We forgot to cherry-pick this into 6.4.0 so far - should we still do it? |
Member
|
Hey @fmeum confirmed with @meteorcloudy -- we're cherry-picking this into 6.4, but this pushes back the release by a bit. |
Member
|
@bazel-io fork 6.4.0 |
bazel-io
pushed a commit
to bazel-io/bazel
that referenced
this pull request
Oct 16, 2023
The values of the internal `$environ` attribute of repository rules is now deduplicated. `ActionEnvironmentFunction#getEnvironmentView`'s signature is updated to receive a `Set` to ensure deduplication for all callers. Previously, a repository rule with duplicate values in `environ` could crash with: ``` FATAL: bazel crashed due to an internal error. Printing stack trace: java.lang.RuntimeException: Unrecoverable error while evaluating node 'REPOSITORY_DIRECTORY:@foo' (requested by nodes 'IGNORED_PACKAGE_PREFIXES:@foo') at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:633) at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:365) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.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.IllegalArgumentException: Multiple entries with same key: FOO=bar and FOO=bar at com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:377) at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:371) at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:241) at com.google.common.collect.RegularImmutableMap.fromEntryArrayCheckingBucketOverflow(RegularImmutableMap.java:132) at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:94) at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:573) at com.google.common.collect.ImmutableMap$Builder.buildOrThrow(ImmutableMap.java:601) at com.google.devtools.build.lib.skyframe.ActionEnvironmentFunction.getEnvironmentView(ActionEnvironmentFunction.java:105) at com.google.devtools.build.lib.rules.repository.RepositoryFunction.getEnvVarValues(RepositoryFunction.java:305) ... ``` Fixes bazelbuild#19244 Closes bazelbuild#19245. PiperOrigin-RevId: 557156429 Change-Id: I454e88b1358cac9a9d787f295fdc9829c57860e4
meteorcloudy
pushed a commit
that referenced
this pull request
Oct 16, 2023
The values of the internal `$environ` attribute of repository rules is now deduplicated. `ActionEnvironmentFunction#getEnvironmentView`'s signature is updated to receive a `Set` to ensure deduplication for all callers. Previously, a repository rule with duplicate values in `environ` could crash with: ``` FATAL: bazel crashed due to an internal error. Printing stack trace: java.lang.RuntimeException: Unrecoverable error while evaluating node 'REPOSITORY_DIRECTORY:@foo' (requested by nodes 'IGNORED_PACKAGE_PREFIXES:@foo') at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:633) at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:365) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.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.IllegalArgumentException: Multiple entries with same key: FOO=bar and FOO=bar at com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:377) at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:371) at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:241) at com.google.common.collect.RegularImmutableMap.fromEntryArrayCheckingBucketOverflow(RegularImmutableMap.java:132) at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:94) at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:573) at com.google.common.collect.ImmutableMap$Builder.buildOrThrow(ImmutableMap.java:601) at com.google.devtools.build.lib.skyframe.ActionEnvironmentFunction.getEnvironmentView(ActionEnvironmentFunction.java:105) at com.google.devtools.build.lib.rules.repository.RepositoryFunction.getEnvVarValues(RepositoryFunction.java:305) ... ``` Fixes #19244 Closes #19245. Commit 49af3d3 PiperOrigin-RevId: 557156429 Change-Id: I454e88b1358cac9a9d787f295fdc9829c57860e4 Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The values of the internal
$environattribute of repository rules is now deduplicated.ActionEnvironmentFunction#getEnvironmentView's signature is updated to receive aSetto ensure deduplication for all callers.Previously, a repository rule with duplicate values in
environcould crash with:Fixes #19244