bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
24.21k stars 4.23k forks source link

errorprone seems to hang the build #25223

Open fzakaria opened 4 months ago

fzakaria commented 4 months ago

Description of the bug:

My builds seem to hang as I go through fixing errorprone bug fixes. When I hit ctrl-c it dumps out a stack-trace:

> bazel build //...
INFO: Invocation ID: 4abeb897-dc62-42fd-92aa-9d5fcd99b61e
INFO: Analyzed 7909 targets (0 packages loaded, 0 targets configured).
[3,523 / 8,277] 12 actions, 11 running
    Building clients/libclients-tests-test-lib-class.jar (102 source files, 1 source jar); 339s disk-cache, multiplex-worker
    Building streams/libstreams-lib-class.jar (682 source files, 1 source jar); 339s disk-cache, multiplex-worker
ERROR: /Users/fzakaria/code/github.com/confluentinc/ce-kafka/clients/BUILD.bazel:330:21: Building clients/libclients-tests-test-lib-class.jar (102 source files, 1 source jar) failed: Worker process returned an unparseable WorkResponse!

Did you try to print something to stdout? Workers aren't allowed to do this, as it breaks the protocol between Bazel and the worker process.

---8<---8<--- Start of response ---8<---8<---
Not UTF-8, printing first 1024 bytes as hex
02 18 03 02 18 09 02 18  0A 02 18 05 02 18 0B 02  |........ ........|
18 0C 02 18 02 02 18 0D  02 18 0E 02 18 06 02 18  |........ ........|
11 02 18 12 02 18 13 02  18 08 02 18 15 02 18 16  |........ ........|
02 18 14 02 18 18 02 18  19 02 18 07 02 18 1B 02  |........ ........|
18 1C 02 18 1D 02 18 0F  02 18 1E AE 08 08 01 12  |........ ........|
A7 08 63 6C 69 65 6E 74  73 2F 73 72 63 2F 74 65  |..client s/src/te|
73 74 2F 6A 61 76 61 2F  6F 72 67 2F 61 70 61 63  |st/java/ org/apac|
68 65 2F 6B 61 66 6B 61  2F 63 6C 69 65 6E 74 73  |he/kafka /clients|
2F 63 6F 6E 73 75 6D 65  72 2F 69 6E 74 65 72 6E  |/consume r/intern|
61 6C 73 2F 53 68 61 72  65 43 6F 6E 73 75 6D 65  |als/Shar eConsume|
52 65 71 75 65 73 74 4D  61 6E 61 67 65 72 54 65  |RequestM anagerTe|
73 74 2E 6A 61 76 61 3A  31 32 39 3A 20 65 72 72  |st.java: 129: err|
6F 72 3A 20 5B 44 6F 75  62 6C 65 42 72 61 63 65  |or: [Dou bleBrace|
49 6E 69 74 69 61 6C 69  7A 61 74 69 6F 6E 5D 20  |Initiali zation] |
50 72 65 66 65 72 20 63  6F 6C 6C 65 63 74 69 6F  |Prefer c ollectio|
6E 20 66 61 63 74 6F 72  79 20 6D 65 74 68 6F 64  |n factor y method|
73 20 6F 72 20 62 75 69  6C 64 65 72 73 20 74 6F  |s or bui lders to|
20 74 68 65 20 64 6F 75  62 6C 65 2D 62 72 61 63  | the dou ble-brac|
65 20 69 6E 69 74 69 61  6C 69 7A 61 74 69 6F 6E  |e initia lization|
20 70 61 74 74 65 72 6E  2E 0A 20 20 20 20 70 72  | pattern ..    pr|
69 76 61 74 65 20 66 69  6E 61 6C 20 4D 61 70 3C  |ivate fi nal Map<|
53 74 72 69 6E 67 2C 20  55 75 69 64 3E 20 74 6F  |String,  Uuid> to|
70 69 63 49 64 73 20 3D  20 6E 65 77 20 48 61 73  |picIds =  new Has|
68 4D 61 70 3C 3E 28 29  20 7B 0A 20 20 20 20 20  |hMap<>()  {.     |
20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                 |
20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                 |
20 20 20 20 20 20 20 20  20 20 5E 0A 20 20 20 20  |           ^.    |
28 73 65 65 20 68 74 74  70 73 3A 2F 2F 65 72 72  |(see htt ps://err|
6F 72 70 72 6F 6E 65 2E  69 6E 66 6F 2F 62 75 67  |orprone. info/bug|
70 61 74 74 65 72 6E 2F  44 6F 75 62 6C 65 42 72  |pattern/ DoubleBr|
61 63 65 49 6E 69 74 69  61 6C 69 7A 61 74 69 6F  |aceIniti alizatio|
6E 29 0A 20 20 44 69 64  20 79 6F 75 20 6D 65 61  |n).  Did  you mea|
6E 20 27 70 72 69 76 61  74 65 20 66 69 6E 61 6C  |n 'priva te final|
20 4D 61 70 3C 53 74 72  69 6E 67 2C 20 55 75 69  | Map<Str ing, Uui|
64 3E 20 74 6F 70 69 63  49 64 73 20 3D 20 6E 65  |d> topic Ids = ne|
77 20 48 61 73 68 4D 61  70 3C 3E 28 49 6D 6D 75  |w HashMa p<>(Immu|
74 61 62 6C 65 4D 61 70  2E 6F 66 28 27 3F 0A 63  |tableMap .of('?.c|
6C 69 65 6E 74 73 2F 73  72 63 2F 74 65 73 74 2F  |lients/s rc/test/|
6A 61 76 61 2F 6F 72 67  2F 61 70 61 63 68 65 2F  |java/org /apache/|
6B 61 66 6B 61 2F 63 6C  69 65 6E 74 73 2F 63 6F  |kafka/cl ients/co|
6E 73 75 6D 65 72 2F 69  6E 74 65 72 6E 61 6C 73  |nsumer/i nternals|
2F 53 68 61 72 65 43 6F  6E 73 75 6D 65 52 65 71  |/ShareCo nsumeReq|
75 65 73 74 4D 61 6E 61  67 65 72 54 65 73 74 2E  |uestMana gerTest.|
6A 61 76 61 3A 31 33 35  3A 20 65 72 72 6F 72 3A  |java:135 : error:|
20 5B 44 6F 75 62 6C 65  42 72 61 63 65 49 6E 69  | [Double BraceIni|
74 69 61 6C 69 7A 61 74  69 6F 6E 5D 20 50 72 65  |tializat ion] Pre|
66 65 72 20 63 6F 6C 6C  65 63 74 69 6F 6E 20 66  |fer coll ection f|
61 63 74 6F 72 79 20 6D  65 74 68 6F 64 73 20 6F  |actory m ethods o|
72 20 62 75 69 6C 64 65  72 73 20 74 6F 20 74 68  |r builde rs to th|
65 20 64 6F 75 62 6C 65  2D 62 72 61 63 65 20 69  |e double -brace i|
6E 69 74 69 61 6C 69 7A  61 74 69 6F 6E 20 70 61  |nitializ ation pa|
74 74 65 72 6E 2E 0A 20  20 20 20 70 72 69 76 61  |ttern..     priva|
74 65 20 66 69 6E 61 6C  20 4D 61 70 3C 53 74 72  |te final  Map<Str|
69 6E 67 2C 20 49 6E 74  65 67 65 72 3E 20 74 6F  |ing, Int eger> to|
70 69 63 50 61 72 74 69  74 69 6F 6E 43 6F 75 6E  |picParti tionCoun|
74 73 20 3D 20 6E 65 77  20 48 61 73 68 4D 61 70  |ts = new  HashMap|
3C 3E 28 29 20 7B 0A 20  20 20 20 20 20 20 20 20  |<>() {.          |
20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                 |
20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                 |
20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                 |
20 20 20 20 20 5E 0A 20  20 20 20 28 73 65 65 20  |     ^.     (see |
68 74 74 70 73 3A 2F 2F  65 72 72 6F 72 70 72 6F  |https:// errorpro|
6E 65 2E 69 6E 66 6F 2F  62 75 67 70 61 74 74 65  |ne.info/ bugpatte|
72 6E 2F 44 6F 75 62 6C  65 42 72 61 63 65 49 6E  |rn/Doubl eBraceIn|
---8<---8<--- End of response ---8<---8<---

---8<---8<--- Exception details ---8<---8<---
java.io.IOException: Worker process for Javac has died
        at com.google.devtools.build.lib.worker.WorkerMultiplexer.getResponse(WorkerMultiplexer.java:329)
        at com.google.devtools.build.lib.worker.WorkerProxy.getResponse(WorkerProxy.java:84)
        at com.google.devtools.build.lib.worker.WorkerSpawnRunner.executeRequest(WorkerSpawnRunner.java:558)
        at com.google.devtools.build.lib.worker.WorkerSpawnRunner.execInWorker(WorkerSpawnRunner.java:414)
        at com.google.devtools.build.lib.worker.WorkerSpawnRunner.exec(WorkerSpawnRunner.java:199)
        at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:158)
        at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:118)
        at com.google.devtools.build.lib.exec.SpawnStrategyResolver.exec(SpawnStrategyResolver.java:45)
        at com.google.devtools.build.lib.rules.java.JavaCompileAction.execute(JavaCompileAction.java:430)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.executeAction(SkyframeActionExecutor.java:1159)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1076)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:165)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:94)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:573)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:862)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:334)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:172)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:461)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:414)
        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)
---8<---8<--- End of exception details ---8<---8<---

---8<---8<--- Start of log, file at /private/var/tmp/_bazel_fzakaria/ff9ce111b6ab17e6476d607385913f63/bazel-workers/multiplex-worker-113-Javac.log ---8<---8<---
(empty)
---8<---8<--- End of log ---8<---8<---
Use --verbose_failures to see the command lines of failed build steps.

Running bazel shutdown seems to fix the issue; so it's some weird in memory bug.

Which category does this issue belong to?

No response

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

No response

Which operating system are you running Bazel on?

MacOS

What is the output of bazel info release?

7.4.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

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

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

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

No response

sgowroji commented 4 months ago

Hi @fzakaria, Is there a way we can reproduce the above usecase at our end.

fzakaria commented 4 months ago

@sgowroji I will see if i can build a reproduction; I noticed it explicitly if i was doing //... and if I had multiple error-prone warnings.

Building smaller number of targets seemed to have worked around the issue. (Or just constantly doing bazel shutdown)

fzakaria commented 4 months ago

It's now happening very often even with smaller targets like "//something/..." with also another exception:

ERROR: /Users/fzakaria/code/github.com/confluentinc/ce-kafka/streams/integration-tests/BUILD.bazel:148:21: Building streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/StreamsUncaughtExceptionHandlerIntegrationTest-class.jar (1 source file) failed: (Exit 1): java failed: error executing Javac command (from target //streams/integration-tests:src/test/java/org/apache/kafka/streams/integration/StreamsUncaughtExceptionHandlerIntegrationTest) external/remotejdk21_macos_aarch64/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 19 arguments skipped)
streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/StreamsUncaughtExceptionHandlerIntegrationTest.java:196: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
            this.context = context;
                         ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:

     error-prone version: 2.23.0
     BugPattern: SelfAssignment
     Stack Trace:
     java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.tree.JCTree$JCMethodDecl.getParameters()" because the return value of "com.google.errorprone.util.ASTHelpers.findEnclosingNode(com.sun.source.util.TreePath, java.lang.Class)" is null
        at com.google.errorprone.bugpatterns.ReplacementVariableFinder.fixesByReplacingExpressionWithMethodParameter(ReplacementVariableFinder.java:88)
        at com.google.errorprone.bugpatterns.SelfAssignment.describeForAssignment(SelfAssignment.java:204)
        at com.google.errorprone.bugpatterns.SelfAssignment.matchAssignment(SelfAssignment.java:83)
        at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:449)
        at com.google.errorprone.scanner.ErrorProneScanner.visitAssignment(ErrorProneScanner.java:504)
        at com.google.errorprone.scanner.ErrorProneScanner.visitAssignment(ErrorProneScanner.java:150)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCAssign.accept(JCTree.java:2070)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
        at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
        at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
        at jdk.compiler/com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:503)
        at com.google.errorprone.scanner.ErrorProneScanner.visitExpressionStatement(ErrorProneScanner.java:633)
        at com.google.errorprone.scanner.ErrorProneScanner.visitExpressionStatement(ErrorProneScanner.java:150)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1611)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
        at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
cushon commented 4 months ago

The crash is an Error Prone bug that I will fix: https://github.com/google/error-prone/issues/4812

This also seems to be showing a number of issues with the JavaBuilder worker and with worker error handling, I'd expect that crash to cause the build to stop and report an error, instead of hanging or logging that stack trace as hex