bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://github.com/bazelbuild/intellij/blob/master/docs/index.md
Apache License 2.0
764 stars 309 forks source link

Reproducible crash after bazel build finish. #4765

Open csitarichie opened 1 year ago

csitarichie commented 1 year ago

Description of the bug:

Got more than one input Future failure. Logging failures after the first

There are 2 exceptions after each other all the time:

java.util.concurrent.ExecutionException: com.google.idea.blaze.base.command.info.BlazeInfoException: blaze info failed with exit code: 2
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:588)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:567)
    at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91)
    at com.google.idea.blaze.base.async.FutureUtil$Builder.lambda$run$0(FutureUtil.java:109)
    at com.google.idea.blaze.base.scope.Scope.push(Scope.java:40)
    at com.google.idea.blaze.base.async.FutureUtil$Builder.run(FutureUtil.java:99)
    at com.google.idea.blaze.base.sync.ProjectStateSyncTask.getProjectState(ProjectStateSyncTask.java:136)
    at com.google.idea.blaze.base.sync.ProjectStateSyncTask.collectProjectState(ProjectStateSyncTask.java:67)
    at com.google.idea.blaze.base.sync.BlazeSyncManager.lambda$requestProjectSync$1(BlazeSyncManager.java:139)
    at com.google.idea.blaze.base.scope.Scope.push(Scope.java:57)
    at com.google.idea.blaze.base.scope.Scope.root(Scope.java:33)
    at com.google.idea.blaze.base.sync.BlazeSyncManager.lambda$requestProjectSync$2(BlazeSyncManager.java:116)
    at com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator.lambda$submitTask$0(ProgressiveTaskWithProgressIndicator.java:83)
    at com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator.lambda$submitTaskWithResult$4(ProgressiveTaskWithProgressIndicator.java:131)
    at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$1(ProgressManager.java:70)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
    at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:70)
    at com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator.lambda$submitTaskWithResult$5(ProgressiveTaskWithProgressIndicator.java:131)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
    at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:248)
    at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:28)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:221)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:227)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:210)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: com.google.idea.blaze.base.command.info.BlazeInfoException: blaze info failed with exit code: 2
    at com.google.idea.blaze.base.command.info.BlazeInfoRunnerImpl.runBlazeInfo(BlazeInfoRunnerImpl.java:102)
    at com.google.idea.blaze.base.command.info.BlazeInfoRunnerImpl.lambda$runBlazeInfo$2(BlazeInfoRunnerImpl.java:72)
    ... 15 more

and

java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
    at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
    at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
    at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
    at java.base/java.util.Objects.checkIndex(Objects.java:359)
    at java.base/java.util.ArrayList.get(ArrayList.java:427)
    at com.google.idea.blaze.base.ideinfo.PyIdeInfo.lambda$parseArgs$0(PyIdeInfo.java:69)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
    at com.google.idea.blaze.base.ideinfo.PyIdeInfo.parseArgs(PyIdeInfo.java:70)
    at com.google.idea.blaze.base.ideinfo.PyIdeInfo.fromProto(PyIdeInfo.java:63)
    at com.google.idea.blaze.base.ideinfo.TargetIdeInfo.fromProto(TargetIdeInfo.java:135)
    at com.google.idea.blaze.base.sync.aspects.BlazeIdeInterfaceAspectsImpl.protoToTarget(BlazeIdeInterfaceAspectsImpl.java:482)
    at com.google.idea.blaze.base.sync.aspects.BlazeIdeInterfaceAspectsImpl.lambda$updateState$6(BlazeIdeInterfaceAspectsImpl.java:358)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
    at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:248)
    at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:28)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:221)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:227)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:210)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

After starting CLion and running bazel sync when the bazel build finished. And starts: Build command finished. Retrieving BEP outputs...

The crash happens and sync fails.

Timing summary:
BlazeInvocation: 308.1s, Prefetching: 1021.3s, Other: 6.8s
Sync failed

the project files for c and c++ remain in unsynced state.

Which Intellij IDE are you using? Please provide the specific version.

2023.1

What programming languages and tools are you using? Please provide specific versions.

c, c++, python, swift

What Bazel plugin version are you using?

2023.03.10.0.1-api-version-231

Have you found anything relevant by searching the web?

there is no information about this crash on the net.

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

No response

Pavank1992 commented 1 year ago

Hi @csitarichie,

While syncing C++ project I am not seeing any issue. Could you please share exact steps to reproduce the issue so we can dive deep into the issue?

csitarichie commented 1 year ago

@Pavank1992

I start Clion with the import BAZEL project and I have .bazelpoject which excludes some directories and I only build a specific sub-target set.

The project uses remote execution and it is huge.

tpasternak commented 1 year ago

@csitarichie what do you mean by remote execution? JetBrains Gateway or Bazel's Remote Execution? It will be hard to investigate without a repro scenario we can run ourselves

csitarichie commented 1 year ago

@csitarichie what do you mean by remote execution? JetBrains Gateway or Bazel's Remote Execution? It will be hard to investigate without a repro scenario we can run ourselves I was suspecting this.

I mean BAZEL remote execution. CLion runs local as well as the repo is local. but the BAZEL build is a remote build.

Unfortunately I can not share the project or even tell details about it. One way could be to write a log by the plugin. And I can run it and see where it is crashes. And try to understand what's is needed to reproduce the problem with an example. I'm not sure what causes the crash and the bazel project is complicated enough to not able to guess what it would be and reproduce it with an example.

tpasternak commented 1 year ago

so what happens if you try to run bazel info from CLI?

csitarichie commented 1 year ago

so what happens if you try to run bazel info from CLI?

WARNING: bazel is now forced to x86_64 as BAZEL_FORCE_X86_64=true
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 45515efb-3ddc-40d3-95d8-34d3f4f616bf
bazel-bin: /private/var/tmp/<repo_cache>/bazel-out/darwin_x86_64-opt/bin
bazel-genfiles: /private/var/tmp/<repo_cache>/bazel-out/darwin_x86_64-opt/bin
bazel-testlogs: /private/var/tmp/<repo_cache>/bazel-out/darwin_x86_64-opt/testlogs
character-encoding: file.encoding = ISO-8859-1, defaultCharset = ISO-8859-1
command_log: /private/var/tmp/<bazel_cache>/command.log
committed-heap-size: 1073MB
execution_root: /private/var/tmp/<repo_cache>
gc-count: 5
gc-time: 17ms
install_base: /var/tmp/<bazel_cache>
java-home: /private/var/tmp/<bazel_cache>/embedded_tools/jdk
java-runtime: OpenJDK Runtime Environment (build 11.0.10+9-LTS) by Azul Systems, Inc.
java-vm: OpenJDK 64-Bit Server VM (build 11.0.10+9-LTS, mixed mode) by Azul Systems, Inc.
max-heap-size: 12884MB
output_base: /private/var/tmp/<bazel_cache>
output_path: /private/var/tmp/<repo_cache>/bazel-out
package_path: %workspace%
release: release 6.1.0-9-g40097e1ba2
repository_cache: /var/tmp/<bazel_tmp>/cache/repos/v1
server_log: /private/var/tmp/<tmp_cache>.java.20230428-125908.2812
server_pid: 2812
used-heap-size: 95MB
workspace: /Users/<repo_root>
tpasternak commented 1 year ago

Interesting. IMO, due to exit code 2, I think it is likely that for some reason bazel info just can't be executed (not in PATH?) by IntelliJ

csitarichie commented 1 year ago

Interesting. IMO, due to exit code 2, I think it is likely that for some reason bazel info just can't be executed (not in PATH?) by IntelliJ

the Bazel sync calls first:

Running Bazel info...
Command: <user_home>/.bazel/bin/bazel info --tool_tag=ijwb:CLion --curses=no --color=yes --progress_in_terminal_title=no --test_output=all --

WARNING: bazel is now forced to x86_64 as BAZEL_FORCE_X86_64=true
INFO: Invocation ID: afbfcb4b-76cc-463c-a739-e6c87a49da89
Building <NNN> Bazel targets...
Build invocation result: success
Parsing build outputs...
Total rules: <NNNN>, new/changed: <NNNN>, removed: 0
Reading IDE info result...
Reading IDE info result...
Updating target map...
Sync failed

Timing summary:
BlazeInvocation: 315.1s, Prefetching: 86.5s, Other: 10.4s
Sync failed

which then starts Bazel build like this:

Command: <user_home>/.bazel/bin/bazel build --tool_tag=ijwb:CLion --keep_going --build_event_binary_file=/var/folders/d2/z4_3dzgx79b1k62rmkt2gqrw0000gn/T/intellij-bep-63399741-e52a-4bd7-92e1-17bb0dce9079 --nobuild_event_binary_file_path_conversion --curses=no --color=yes --progress_in_terminal_title=no --test_output=all --noexperimental_run_validations --aspects=@@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect "--override_repository=intellij_aspect=<user_home>/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-1/231.8109.222/CLion 2023.1 EAP.app.plugins/clwb/aspect" --output_groups=intellij-resolve-cpp,intellij-resolve-py,intellij-info-cpp,intellij-info-generic,intellij-info-py -- //<incuded_dir>/... -<excluded_dir>/...

the build finishes like this:

INFO: Build completed successfully, <NNN> total actions
INFO: Build Event Protocol files produced successfully.
INFO: Build completed successfully, <NNN> total actions
Build command finished. Retrieving BEP outputs...

and there is an exception:

Got more than one input Future failure. Logging failures after the first

java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
    at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
    at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
    at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
    at java.base/java.util.Objects.checkIndex(Objects.java:359)
    at java.base/java.util.ArrayList.get(ArrayList.java:427)
    at com.google.idea.blaze.base.ideinfo.PyIdeInfo.lambda$parseArgs$0(PyIdeInfo.java:69)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
    at com.google.idea.blaze.base.ideinfo.PyIdeInfo.parseArgs(PyIdeInfo.java:70)
    at com.google.idea.blaze.base.ideinfo.PyIdeInfo.fromProto(PyIdeInfo.java:63)
    at com.google.idea.blaze.base.ideinfo.TargetIdeInfo.fromProto(TargetIdeInfo.java:135)
    at com.google.idea.blaze.base.sync.aspects.BlazeIdeInterfaceAspectsImpl.protoToTarget(BlazeIdeInterfaceAspectsImpl.java:482)
    at com.google.idea.blaze.base.sync.aspects.BlazeIdeInterfaceAspectsImpl.lambda$updateState$6(BlazeIdeInterfaceAspectsImpl.java:358)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
    at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:248)
    at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:28)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:221)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:227)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:210)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)

So to me it seems that the failure is during Retrieving BEP outputs...

csitarichie commented 1 year ago

It seems that the crash is gone if I'm disabling python as additional languages:

additional_languages:
  # python
tpasternak commented 1 year ago

So it seems that there's something specific in the one of the args in py_binary. If you can't share it, you can try by yourself by running:

  1. Double-press shift
  2. IDE scripting console
  3. Paste com.intellij.util.execution.ParametersListUtil.parse(arg, false, false) for each entry in args separately
  4. press ctrl+enter (or cmd + enter on mac)