-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash when environ
contains duplicate entries
#19245
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) ... ```
...ain/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java
Outdated
Show resolved
Hide resolved
This probably warrants a 6.3.3 |
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. |
@Wyverald We forgot to cherry-pick this into 6.4.0 so far - should we still do it? |
Hey @fmeum confirmed with @meteorcloudy -- we're cherry-picking this into 6.4, but this pushes back the release by a bit. |
@bazel-io fork 6.4.0 |
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
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>
The values of the internal
$environ
attribute of repository rules is now deduplicated.ActionEnvironmentFunction#getEnvironmentView
's signature is updated to receive aSet
to ensure deduplication for all callers.Previously, a repository rule with duplicate values in
environ
could crash with:Fixes #19244