bazelbuild / bazel

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

ijar tool fails with segmentation fault #14645

Open sholokhov opened 2 years ago

sholokhov commented 2 years ago

Description of the problem / feature request:

I'm trying to migrate from bazel 4.2.2 to bazel 5.0.0 on Scala monorepo (with rules_scala) and started to see the following error:

ERROR: /home/sholokhov/code/xite/3rdparty/jvm/com/github/pureconfig/BUILD:20:13: StampWithIjar 3rdparty/jvm/com/github/pureconfig/pureconfig_core.stamp/com_github_pureconfig_pureconfig_core_2_13-stamped.jar failed: (Segmentation fault): ijar failed: error executing command 
  (cd /home/sholokhov/.cache/bazel/_bazel_sholokhov/d1dee1b302471130bebbc47f621d2c9b/sandbox/linux-sandbox/58/execroot/xite && \
  exec env - \
  external/remote_java_tools_linux/java_tools/ijar/ijar --nostrip_jar --target_label //3rdparty/jvm/com/github/pureconfig:pureconfig_core external/com_github_pureconfig_pureconfig_core_2_13/jar/com_github_pureconfig_pureconfig_core_2_13.jar bazel-out/k8-fastbuild/bin/3rdparty/jvm/com/github/pureconfig/pureconfig_core.stamp/com_github_pureconfig_pureconfig_core_2_13-stamped.jar)
# Configuration: 9f72dbfc6067cba8c7182abbe35db7759aa1626e954083725070236a790fcf64
# Execution platform: @local_config_platform//:host

Looks like ijar fails with segfault during jar stamping step. It works perfectly fine with bazel 4 series (tested on 4.2.1 and 4.2.2).

What operating system are you running Bazel on?

Linux nzxt 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

What's the output of bazel info release?

release 5.0.0

cushon commented 2 years ago

There was another report of this in slack

Do you have a repro, or can you share the jar it's crashing on in the bug?

sholokhov commented 2 years ago

Apparently this is a problem for specific jar (pureconfig), I was able to find similar issues for the same Scala artifact:

Its weird that it has been working for us on bazel 4.x and earlier but started to break on 5.x. Closing this as a duplicate of https://github.com/bazelbuild/bazel/issues/13943.

ahmedyarub commented 9 months ago

It's not just for a specific jar. I can see a lot of other complaints about some random jars failing including us. I have some jars that I need urgently for my project and I can extract them on MacOS without any problem, but when used as a part of build I get that segmentation fault.

cushon commented 9 months ago

Do you have a repro, or can you share one of the jars it's crashing on in the bug?

ahmedyarub commented 9 months ago

We build some internal plugins that use compiled versions of IntelliJ-Community edition compiled by us. We have been doing this for years without any problem. Then suddenly when upgraded to Java 17 + latest EAP the files started throwing these errors. Using --nous_ijars mitigated the problems but that is not really a solution. I'll consult my company and try to get you binaries and/or scripts.

cushon commented 4 months ago

There were some other reports of ijar segfaults here:

For anyone seeing this, can you share one of the jars ijar is crashing on in the bug?

youmna-rabie commented 3 months ago

@cushon I'm seeing this ERROR: /private/var/tmp/_bazel_youmna.rabie/a3f73e9053c6872ac891025dc8e34184/external/commons_codec_commons_codec/jar/BUILD:3:12: Extracting interface @commons_codec_commons_codec//jar:jar failed: (Segmentation fault): ijar failed: error executing command external/remote_java_tools_darwin/java_tools/ijar/ijar external/commons_codec_commons_codec/jar/commons_codec_commons_codec.jar ... (remaining 3 arguments skipped)

On

Build label: 5.1.1
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Apr 8 15:58:49 2022 (1649433529)
Build timestamp: 1649433529
Build timestamp as int: 1649433529
cushon commented 3 months ago

@youmna-rabie can you share one of the jars ijar is crashing on, perhaps by attaching it to a comment on this bug?

youmna-rabie commented 3 months ago

@cushon I'm not able to share a JAR on here as it's not a supported file type, but here's a Google Drive link with the jar folder.

cushon commented 3 months ago

I can reproduce with the version of ijar in Bazel 5.1.1, but not with the latest versions of ijar, this bug seems to have been fixed. Can you try using a newer version of Bazel?

youmna-rabie commented 3 months ago

Do you know the lowest version of bazel that would have fixed this? This is a legacy code base that isn't easily upgrade-able unfortunately :/

cushon commented 3 months ago

The ijar fix was https://github.com/bazelbuild/bazel/commit/3954a18fa6b0e3d1a1005cc3409ebc95f6adf3af

I think Bazel 7.x is the first version to include that, specifically in https://github.com/bazelbuild/bazel/commit/9f0b235f162093b8e93a4dc2ae0c1844a56843d2

cushon commented 3 months ago

Actually 6.3.0 also had the fix: https://github.com/bazelbuild/bazel/commit/dc1c7b39dcfcdc75433a3f5792818149788dd885

youmna-rabie commented 3 months ago

Thanks, upgrading to 6.3.0 resolved it!