Skip to content

Build outcome is inaccurate and differs on different platforms #4108

Closed

Description

@davido
  1. Try to build gerrit code review from this commit (75fa62c694c987d1768017131533d7a9aa45b9da) on Linux:
$ bazel build java/com/google/gerrit/server/diff:diff -s 
INFO: Analysed target //java/com/google/gerrit/server/diff:diff (37 packages loaded).
INFO: Found 1 target...
SUBCOMMAND: # //java/com/google/gerrit/server/diff:diff [action 'Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor)']
(cd /home/davido/.cache/bazel/_bazel_davido/5c01f4f713b675540b8b424c5c647f63/execroot/gerrit && \
  exec env - \
    LC_CTYPE=en_US.UTF-8 \
  external/local_jdk/bin/java -XX:+TieredCompilation '-XX:TieredStopAtLevel=1' -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9-dev-r4023-3.jar -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/k8-fastbuild/bin/java/com/google/gerrit/server/diff/libdiff.jar-2.params)
Target //java/com/google/gerrit/server/diff:diff up-to-date:
  bazel-bin/java/com/google/gerrit/server/diff/libdiff.jar
INFO: Elapsed time: 4.139s, Critical Path: 0.92s
INFO: Build completed successfully, 3 total actions

it will succeed, where the libdiff.jar-2.params - file on Linux is here: http://paste.openstack.org/show/626680.

  1. From the same gerrit commit, with the same Bazel version, I used 0.8.0-rc2, try to build the same rule on Windows:
$ bazel build  java/com/google/gerrit/server/diff:diff -s
SUBCOMMAND: # //java/com/google/gerrit/server/diff:diff [action 'Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor)']
cd C:/msys64/tmp/_bazel_davido/_biltsqa/execroot/gerrit
  SET LC_CTYPE=en_US.UTF-8
  external/local_jdk/bin/java.exe -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9-dev-r4023-3.jar -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/x64_windows-fastbuild/bin/java/com/google/gerrit/server/diff/libdiff.jar-2.params
[54 / 55] Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor); 1s worker
ERROR: C:/users/davido/projects/gerrit/java/com/google/gerrit/server/diff/BUILD:1:1: Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor) failed (Exit 1)
bazel-out\x64_windows-fastbuild\bin\java\com\google\gerrit\server\diff\_javac\diff\libdiff_sourcegenfiles\com\google\gerrit\server\diff\AutoValue_IntraLineDiffArgs.java:105: error: incompatible types: NameKey cannot be converted to Object
           && (this.project.equals(that.project()))
                                               ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
Target //java/com/google/gerrit/server/diff:diff failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 44,308s, Critical Path: 4,68s
FAILED: Build did NOT complete successfully

where the libdiff.jar-2.params - file in Windows is here: http://paste.openstack.org/show/626690.

It turns out, that the root cause is missing transitive dependency on gwtorm.jar that was fixed here: [1]. I've created a reproducer: [2].

It seems that the problem is reported by error prone, in compilation unit, that was generated by annotation processor (auto-value). I wrote this issue to improve the misleading error message: #4105.

This issue is to track the different build outcomes on Linux and Windows: success vs. failure, correspondingly.

Activity

  1. davido commented on Nov 19, 2017

    @davido
    ContributorAuthor

    //CC @cushon @damienmg

    It seems that inaccuracy and bad buid outcome is caused by error prone. If I disable all checks on Windows by passing this bazel option: --javacopt=-XepDisableAllChecks, the build succeeds (as it does on Linux without disabling error prone checks):

    $ bazel build --javacopt=-XepDisableAllChecks java/com/google/gerrit/server/diff:diff -s
    [...]
    SUBCOMMAND: # //java/com/google/gerrit/common:server [action 'Building java/com/google/gerrit/common/libserver.jar (57 source files)']
    cd C:/msys64/tmp/_bazel_davido/_biltsqa/execroot/gerrit
      SET LC_CTYPE=en_US.UTF-8
      external/local_jdk/bin/java.exe -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9-dev-r4023-3.jar -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/x64_windows-fastbuild/bin/java/com/google/gerrit/common/libserver.jar-2.params
    SUBCOMMAND: # //java/com/google/gerrit/server/diff:diff [action 'Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor)']
    cd C:/msys64/tmp/_bazel_davido/_biltsqa/execroot/gerrit
      SET LC_CTYPE=en_US.UTF-8
      external/local_jdk/bin/java.exe -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9-dev-r4023-3.jar -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/x64_windows-fastbuild/bin/java/com/google/gerrit/server/diff/libdiff.jar-2.params
    [54 / 55] Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor); 1s worker
    Target //java/com/google/gerrit/server/diff:diff up-to-date:
      C:/msys64/tmp/_bazel_davido/_biltsqa/execroot/gerrit/bazel-out/x64_windows-fastbuild/bin/java/com/google/gerrit/server/diff/libdiff.jar
    INFO: Elapsed time: 4,891s, Critical Path: 4,22s
    INFO: Build completed successfully, 37 total actions
    
  2. cushon commented on Nov 19, 2017

    @cushon
    Contributor

    Do you have a minimal repro for the part of this that only happens on windows?

    I don't have access to a windows machine right now, would you mind adding javacopts = ["-verbose"] to //java/com/google/gerrit/server/diff:diff and then sharing the log output for that action for both windows and linux?

  3. davido commented on Nov 19, 2017

    @davido
    ContributorAuthor

    @cushon Sure, it took me quite some time to extract the minimal reproducer for this breakage from Gerrit Code Review and gwtorm. See this repro https://github.com/davido/bazel-annotation-processor-breakage. I also was able to eliminate all external deps, except auto-value.

    I also filed this issue upstream: [1].

    I don't have access to a windows machine right now, would you mind adding javacopts = ["-verbose"] to //java/com/google/gerrit/server/diff:diff and then sharing the log output for that action for both windows and linux?

    • Verbose execution under Linux: [2]
    • Verbose execution under Windows: [3]

    Looking into the verbose output, as expected, the root cause is the missing dependency on indirect dependency on Windows on gwtorm:client:

    Windows

    [search path for class files:
    
    external\local_jdk\jre\lib\rt.jar,
    external\local_jdk\jre\lib\resources.jar,
    external\local_jdk\jre\lib\jsse.jar,
    external\local_jdk\jre\lib\jce.jar,
    external\local_jdk\jre\lib\charsets.jar,
    external\local_jdk\jre\lib\ext\access-bridge-64.jar,
    external\local_jdk\jre\lib\ext\cldrdata.jar,
    external\local_jdk\jre\lib\ext\dnsns.jar,
    external\local_jdk\jre\lib\ext\jaccess.jar,
    external\local_jdk\jre\lib\ext\jfxrt.jar,
    external\local_jdk\jre\lib\ext\localedata.jar,
    external\local_jdk\jre\lib\ext\nashorn.jar,
    external\local_jdk\jre\lib\ext\sunec.jar,
    external\local_jdk\jre\lib\ext\sunjce_provider.jar,
    external\local_jdk\jre\lib\ext\sunmscapi.jar,
    external\local_jdk\jre\lib\ext\sunpkcs11.jar,
    external\local_jdk\jre\lib\ext\zipfs.jar,
    
    bazel-out\x64_windows-fastbuild\bin\java\com\google\gerrit\reviewdb\libserver-hjar.jar,
    bazel-out\x64_windows-fastbuild\genfiles\external\auto_value\jar\_ijar\jar\external\auto_value\jar\auto-value-1.5.2-ijar.jar]
    

    Whereas on Linux indirect dependency on gwtorm:client is there:

    Linux

    [...]
    bazel-out/k8-fastbuild/bin/java/com/google/gwtorm/libclient-hjar.jar
    
  4. added
    P2
    on Nov 20, 2017
  5. cushon commented on Nov 20, 2017

    @cushon
    Contributor

    Thanks for taking the time to make the repro! I think there's a second bug here preventing gwtorm:client from being on the classpath for the windows build.

    Can you share the contents of bazel-bin/java/com/google/gerrit/reviewdb/libserver-hjar.jdeps from the windows build? And do either of --java_classpath=off or --nojava_header_compilation make a difference?

  6. davido commented on Nov 20, 2017

    @davido
    ContributorAuthor

    Can you share the contents of bazel-bin/java/com/google/gerrit/reviewdb/libserver-hjar.jdeps from the windows build?

    Here is the content of bazel-bin/java/com/google/gerrit/reviewdb/libserver-hjar.jdeps:

    $ cat bazel-bin/java/com/google/gerrit/reviewdb/libserver-hjar.jdeps
    
    Q
    Mbazel-out\x64_windows-fastbuild\bin\java\com\google\gwtorm\libclient-hjar.jar
    %
    !external\local_jdk\jre\lib\rt.jar(//java/com/google/gerrit/reviewdb:server
    

    And do either of --java_classpath=off

    Indeed, passing --java_classpath=off did fix it:

    $ bazel build --java_classpath=off java/com/google/gerrit/server/diff
    Loading:
    Loading: 0 packages loaded
    INFO: Analysed target //java/com/google/gerrit/server/diff:diff (0 packages loaded).
    INFO: Found 1 target...
    [1 / 11] BazelWorkspaceStatusAction stable-status.txt
    Target //java/com/google/gerrit/server/diff:diff up-to-date:
      C:/msys64/tmp/_bazel_davido/dl4nuxf6/execroot/bazel_annotation_processor_breakage/bazel-out/x64_windows-fastbuild/bin/java/com/google/gerrit/server/diff/libdiff.jar
    INFO: Elapsed time: 1,756s, Critical Path: 1,02s
    INFO: Build completed successfully, 9 total actions
    

    or --nojava_header_compilation make a difference?

    Passing --nojava_header_compilation didn't fix it:

    $ bazel build --nojava_header_compilation java/com/google/gerrit/server/diff
    Loading:
    Loading: 0 packages loaded
    INFO: Analysed target //java/com/google/gerrit/server/diff:diff (0 packages loaded).
    INFO: Found 1 target...
    [0 / 10] BazelWorkspaceStatusAction stable-status.txt
    ERROR: C:/users/davido/projects/bazel-annotation-processor-breakage/java/com/google/gerrit/server/diff/BUILD:3:1: Building java/com/google/gerrit/server/diff/libdiff.jar (1 source file) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor) failed (Exit 1)
    bazel-out\x64_windows-fastbuild\bin\java\com\google\gerrit\server\diff\_javac\diff\libdiff_sourcegenfiles\com\google\gerrit\server\diff\AutoValue_IntraLineDiffArgs.java:51: error: incompatible types: NameKey cannot be converted to Object
          return (this.project.equals(that.project()))
                                                  ^
    Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
    Target //java/com/google/gerrit/server/diff:diff failed to build
    Use --verbose_failures to see the command lines of failed build steps.
    INFO: Elapsed time: 1,525s, Critical Path: 0,81s
    FAILED: Build did NOT complete successfully
    
  7. cushon commented on Nov 20, 2017

    @cushon
    Contributor

    Can you attach libserver-hjar.jdeps to the bug? It's a binary proto.

  8. davido commented on Nov 20, 2017

    @davido
    ContributorAuthor

    Can you attach libserver-hjar.jdeps to the bug? It's a binary proto.

    Done libserver-hjar.zip.

  9. cushon commented on Nov 20, 2017

    @cushon
    Contributor

    JavaBuilder compares paths as strings when computing reduced class paths. The params file contains /-separated paths like bazel-out/msvc_x64-fastbuild/bin/java/com/google/gwtorm/libclient-hjar.jar, and the jdeps files contain \-separated paths like bazel-out\msvc_x64-fastbuild\bin\java\com\google\gwtorm\libclient-hjar.jar.

  10. cushon commented on Nov 20, 2017

    @cushon
    Contributor

    @meteorcloudy - I'm surprised Bazel is using /-separated paths for params files on Windows (see the paste in the original comment: http://paste.openstack.org/show/626690/). Is that expected behaviour?

  11. meteorcloudy commented on Nov 21, 2017

    @meteorcloudy
    Member

    Yes, for some reasons we still use / as seperator, I think it should work fine on Windows with Java.

    private static class Helper extends PathFragment.Helper {
    private static final char SEPARATOR_CHAR = '/';
    // TODO(laszlocsomor): Lots of internal PathFragment operations, e.g. getPathString, use the
    // primary separator char and do not use this.
    private static final char EXTRA_SEPARATOR_CHAR = '\\';

    I wonder where does \ come from?

    FYI, @laszlocsomor

  12. cushon commented on Nov 21, 2017

    @cushon
    Contributor

    The \ comes from JavaBuilder, which is writing out a .jdeps proto containing paths to some of the entries on the classpath. Those paths round-trip through java.nio.file.Path, which uses the platform default path separator when they get converted back to strings.

    Out of curiosity, why is / still used on Windows?

  13. laszlocsomor commented on Nov 21, 2017

    @laszlocsomor
    Contributor

    @meteorcloudy : FYI, I didn't add that TODO, @haxorz did.

  14. 19 remaining items

  15. davido commented on Nov 23, 2017

    @davido
    ContributorAuthor

    I'm wondering if we should be looking for a work-around.

    @cushon As you suggested, the workaround is here: [1]. I tested it with my reproducer on both platforms Linux and Windows. It works as expected.

  16. laszlocsomor commented on Nov 23, 2017

    @laszlocsomor
    Contributor

    @davido, thanks for your patch!
    I'm looking at changing the path separators for Windows. I expect it will break some tests I'm not yet aware of.

  17. dslomov commented on Nov 23, 2017

    @dslomov
    Contributor

    Our release policy is clear: not a regression => no cherry-pick and no release blockage (https://bazel.build/support.html#releases)
    Given that this survived at least one release, the problem is not that acute.

  18. dslomov commented on Nov 23, 2017

    @dslomov
    Contributor

    I think the right fix is for Java tools to be robust and accept multiple valid path representations

    Are there disadvantages to also using the platform-dependent name separator in Bazel?

    The more uniform platform-independent commands are, the better (for remote execution, action cache, etc).
    The present issue is in Java tools - Bazel gives valid (on Windows) command lines to Java tools, and Java tools do not handle them correctly- so let's fix it there.

  19. davido commented on Nov 24, 2017

    @davido
    ContributorAuthor

    I would define this issue as release blocker and wait with releasing 0.8 until it is fixed.

    Our release policy is clear: not a regression => no cherry-pick and no release blockage (https://bazel.build/support.html#releases)

    OTOH, The release policy is also claiming that:

    Only critical, high-impact bugs will be fixed in a release candidate.
    

    Given that nothing causes more pain, frustration, and disappointment than unfulfilled expectations. As mentioned in the original report to this issue,

    Linux

      $ bazel build java/com/google/gerrit/server/diff:diff
      Pass
    

    Windows

      $ bazel build java/com/google/gerrit/server/diff:diff
      broken
    

    Needless to say, I was shocked to find out, that a simple java_library rule -- no any system specifics like genrule or what not involved -- works on Linux and is failing on Windows.

    So my POV that we are talking about critical and high-impact bug: reliability and accuracy of build outcome. What else can compromise a build tool, when its outcome is flaky?

    Very recently, Bazel team removed the notice from the FAQ, that Bazel on Windows platform is highly experimented, bleeding edge and may produce unexpected results.

    Last but not least, Bazel has this slogan on its main page:

    Build and test software of any size, quickly and reliably
    

    I suggest, you remove reliably untill bazel build foo for simple java_library rule produces the same (!) results on all supported platforms. Or your stop claiming that platform X is 100% supported platform, unless you have opened issues (with existing workarounds that you are rejecting to cherry-pick) causing transitive classpath computation to be inherently broken. IOW, revert this CL.

    I'm really not amused with your assessment of that issue (as you may have noticed). One reason for it, is because Gerrit Code Review project's founder promissed me in person that Bazel team is going to be very supportive for Gerrit Code Review issues, for reasons (that I'm not going to enter into here).

  20. dslomov commented on Nov 24, 2017

    @dslomov
    Contributor

    David, I agree this is an important bug to fix, and we will fix it. I think it should block the next (0.9) release.
    On the other hand, every software project has bugs, and whenever the user is hit by a bug, that bug is, for that user, the most important thing and the biggest fault of the project ("the sky is falling").

    In this case, we just have no evidence that many users are hit by this specific issue: the issue is not a regression, it has been present in more than one release, we build multiple large projects with Bazel very regularly (including on ci.bazel.build), we have multiple large customers with substantial Java codebases, and nobody yet complained. There are workarounds (disable errorprone) that will get you through until this issue is fixed. There is no justification whatsoever to block 0.8 release on this.

  21. davido commented on Nov 25, 2017

    @davido
    ContributorAuthor

    [...] the workaround is here: [1]. I tested it with my reproducer on both platforms Linux and Windows. It works as expected.
    [1] https://bazel-review.googlesource.com/#/c/bazel/+/22730

    I was looking into adding a test, for the CL above, as was requested in review. It seems that a similar test already exists. So that I was curious, whether or not this test still works with the diff applied.

    Unfortunately, the java_tools don't work here. I wrote this issue: #4165.

  22. meteorcloudy commented on Nov 27, 2017

    @meteorcloudy
    Member

    @davido There is a internal change under review from @cushon, which will fix this problem in a more principle way, maybe we can just wait for that one. :)

  23. davido commented on Nov 27, 2017

    @davido
    ContributorAuthor

    @meteorcloudy @cushon

    Thanks. I abandoned my CL.

  24. cushon commented on Nov 28, 2017

    @cushon
    Contributor

    The work-around was submitted as 0b2352d.

  25. davido commented on Nov 28, 2017

    @davido
    ContributorAuthor

    The work-around was submitted as 0b2352d.

    Works like a charm, thanks!

  26. laszlocsomor commented on Nov 28, 2017

    @laszlocsomor
    Contributor

    Update:

    • @cushon submitted a principled fix to JavaBuilder in 0b2352d, which fixed this bug.
    • I looked at changing the code to use \ on Windows, but gave up because there are hundreds of call sites and I didn't want to go ahead and audit all, and also:
    • @tomlu is working on a design proposal to tighten path semantics inside Bazel, and I'd rather he did the work, not me ;)
  27. tomlu commented on Nov 28, 2017

    @tomlu
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P1platform: windowstype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions