bazel: NullPointerException when overriding copts and linkopts to None in transition

Description of the problem / feature request:

When overriding the copts and linkopts build configuration with None values in a transition, Bazel crashes with a NullPointerException.

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

def _my_transition_impl(settings, attr):
    return {
        "//command_line_option:copt": None,
        "//command_line_option:linkopt": None,
    }

my_transition = transition(
    implementation = _my_transition_impl,
    inputs = [],
    outputs = [
        "//command_line_option:copt",
        "//command_line_option:linkopt",
    ],
)

What operating system are you running Bazel on?

Debian-based Linux.

What’s the output of bazel info release?

release 3.7.1

What’s the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

git@github.com:bazelbuild/rules_fuzzing
f782cd326f15a1182a3c293cf77f3a21f0b24ed0
b0e592b75de5680599ee81ccec6b073e93a21058

Have you found anything relevant by searching the web?

No.

Any other information, logs, or outputs that you want to share?

The exception stack trace:

Internal error thrown during build. Printing stack trace: java.lang.RuntimeException: Unrecoverable error while evaluating node 'BuildConfigurationValue.Key[f380618cb25b3c02e111c0b5e52b926621d76dbf320be25008319e76d414f029]' (requested by nodes 'ConfiguredTargetKey{label=//examples:re2_fuzz_test_instrum, config=BuildConfigurationValue.Key[8f956e0a5a332769538bb1785bbb03d792f84521f14f8711180a17d7de3e07e8]}')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:513)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:398)
        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: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException
        at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2051)
        at com.google.common.cache.LocalCache.get(LocalCache.java:3951)
        at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
        at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4958)
        at com.google.devtools.build.lib.skyframe.BuildConfigurationFunction.getConfigurationFragments(BuildConfigurationFunction.java:127)
        at com.google.devtools.build.lib.skyframe.BuildConfigurationFunction.compute(BuildConfigurationFunction.java:84)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:438)
        ... 7 more
Caused by: java.lang.NullPointerException
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:878)
        at com.google.common.collect.ImmutableList$Builder.addAll(ImmutableList.java:823)
        at com.google.devtools.build.lib.rules.cpp.CppConfiguration.create(CppConfiguration.java:182)
        at com.google.devtools.build.lib.rules.cpp.CppConfigurationLoader.create(CppConfigurationLoader.java:49)
        at com.google.devtools.build.lib.rules.cpp.CppConfigurationLoader.create(CppConfigurationLoader.java:27)
        at com.google.devtools.build.lib.skyframe.BuildConfigurationFunction.makeFragment(BuildConfigurationFunction.java:158)
        at com.google.devtools.build.lib.skyframe.BuildConfigurationFunction.access$000(BuildConfigurationFunction.java:45)
        at com.google.devtools.build.lib.skyframe.BuildConfigurationFunction$2.load(BuildConfigurationFunction.java:59)
        at com.google.devtools.build.lib.skyframe.BuildConfigurationFunction$2.load(BuildConfigurationFunction.java:56)
        at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3529)
        at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2278)
        at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2155)
        at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2045)
        ... 13 more

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Hey! Sorry about the delay - thanks, that makes sense. First approach sounds good to me - consistent, and probably safe enough to infer that the user actually means []. I’m looking into it now.