Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google-closure-compiler-linux throwing Java exceptions. #234

Closed
robertfirek opened this issue Apr 8, 2022 · 17 comments
Closed

google-closure-compiler-linux throwing Java exceptions. #234

robertfirek opened this issue Apr 8, 2022 · 17 comments

Comments

@robertfirek
Copy link

Executing the following command:

npx google-closure-compiler target/resources/main/js/es6-bundle.js > target/resources/main/js/es5-bundle.js --language_in=ECMASCRIPT_2017 --language_out=ECMASCRIPT5 --compilation_level=SIMPLE_OPTIMIZATIONS --rewrite_polyfills=true --warning_level=QUIET --jscomp_off=checkVars --create_source_map target/resources/main/js/es5-bundle.js.map

produces the following error statement:

java.util.zip.ZipException: invalid entry CRC (expected 0x4e1f14a4 but got 0xb1e0eb5b)
        at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:410)
        at java.util.zip.ZipInputStream.read(ZipInputStream.java:199)
        at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:143)
        at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:121)
        at com.google.javascript.jscomp.AbstractCommandLineRunner.getBuiltinExterns(AbstractCommandLineRunner.java:481)
        at com.google.javascript.jscomp.CommandLineRunner.createExterns(CommandLineRunner.java:2073)
        at com.google.javascript.jscomp.AbstractCommandLineRunner.doRun(AbstractCommandLineRunner.java:1168)
        at com.google.javascript.jscomp.AbstractCommandLineRunner.run(AbstractCommandLineRunner.java:532)
        at com.google.javascript.jscomp.CommandLineRunner.main(CommandLineRunner.java:2231)

I confirmed that the native compiler is executed in this case (from google-closure-compiler-linux package). Force refresh and reinstallation of modules doesn't fix the problem.

Versions:
"20220202.0.0", "20220405.0.0"

Operating system:
Linux 5.10.105-1-MANJARO x86_64

Java version:
openjdk 11.0.14 2022-01-18
OpenJDK Runtime Environment Temurin-11.0.14+9 (build 11.0.14+9)
OpenJDK 64-Bit Server VM Temurin-11.0.14+9 (build 11.0.14+9, mixed mode)

@brad4d
Copy link
Collaborator

brad4d commented Apr 8, 2022

I've tried to reproduce this problem without success using a JS file I had hanging around.

npx google-closure-compiler \
    regex_test.js \
    --language_in=ECMASCRIPT_2017 \
    --language_out=ECMASCRIPT5 \
    --compilation_level=SIMPLE_OPTIMIZATIONS \
    --rewrite_polyfills=true \
    --warning_level=QUIET \
    --jscomp_off=checkVars \
    --create_source_map test.sourcemap

I got the output I expected.

Here's relevant version information

$ npx --version
8.5.1

$ npx google-closure-compiler --version
Closure Compiler (http://github.com/google/closure-compiler)
Version: v20220405

$ java --version
openjdk 11.0.14 2022-01-18
OpenJDK Runtime Environment (build 11.0.14+9-post-Debian-1)
OpenJDK 64-Bit Server VM (build 11.0.14+9-post-Debian-1, mixed mode, sharing)

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux rodete
Release:	rodete
Codename:	rodete

$ uname -r
5.15.15-1rodete2-amd64

@noppa
Copy link

noppa commented Apr 8, 2022

I also started running to this today. I'm not on computer right now so can't check all the specs for you yet, but what I do notice right away is that, like OP, I'm also using Manjaro

@lbguilherme
Copy link

I'm also having the exact same issue, on ArchLinux (inside WSL).

@brad4d
Copy link
Collaborator

brad4d commented Apr 11, 2022

Since I was unable to reproduce this problem with the latest release, and I doubt any of my coworkers can either.
I think we'll be dependent on folks in the OSS community to figure out what is happening here.

@lbguilherme
Copy link

Here is a single command that will reproduce the problem:

docker run --rm -ti archlinux bash -c "yes | pacman -Sy npm && \
npm i -g google-closure-compiler && google-closure-compiler --version && google-closure-compiler a.js; bash"
Closure Compiler (http://github.com/google/closure-compiler)
Version: v20220405
java.util.zip.ZipException: invalid entry CRC (expected 0x4e1f14a4 but got 0xb1e0eb5b)
        at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:410)
        at java.util.zip.ZipInputStream.read(ZipInputStream.java:199)
        at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:143)
        at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:121)
        at com.google.javascript.jscomp.AbstractCommandLineRunner.getBuiltinExterns(AbstractCommandLineRunner.java:481)
        at com.google.javascript.jscomp.CommandLineRunner.createExterns(CommandLineRunner.java:2083)
        at com.google.javascript.jscomp.AbstractCommandLineRunner.doRun(AbstractCommandLineRunner.java:1168)
        at com.google.javascript.jscomp.AbstractCommandLineRunner.run(AbstractCommandLineRunner.java:532)
        at com.google.javascript.jscomp.CommandLineRunner.main(CommandLineRunner.java:2241)

@niloc132
Copy link

I've reproduced it also - you must specifically install npx for your platform and then run

$ npx google-closure-compiler

to get the issue. This immediately reproduces the problem, though doesn't make clear what the failure actually was.

Next I downloaded the actual executable from npmjs.com
https://registry.npmjs.com/google-closure-compiler-java/-/google-closure-compiler-java-20220405.0.0.tgz

Untarred, this contains a file package/compiler.jar, which starts up correctly.

In the debug logs for the failure above, I also found a different link, which better matches the issue's title:
https://registry.npmjs.com/google-closure-compiler-linux/-/google-closure-compiler-linux-20220405.0.0.tgz

This apparently contains an x86 linux binary in package/compiler, according to https://www.npmjs.com/package/google-closure-compiler-linux this is a

Linux native platform distribution of Closure Compiler.

Running this file is what results in the failure seen above. https://github.com/google/closure-compiler/#getting-started also references this binary distribution, as does https://www.npmjs.com/package/google-closure-compiler#user-content-native-binary-version.

I don't know how to build this distribution from the git repo with bazel, so I'm limited to stopping there and letting someone else take a look as to why the copy at npmjs.com might be corrupt somehow.

@brad4d brad4d transferred this issue from google/closure-compiler Apr 11, 2022
@brad4d
Copy link
Collaborator

brad4d commented Apr 11, 2022

@ChadKillingsworth does this look like there's something wrong with the Graal build to you?

@ChadKillingsworth
Copy link
Collaborator

I'm not sure. It could be.

@brad4d
Copy link
Collaborator

brad4d commented Apr 12, 2022

When I use npx google-closure-compiler, how can I tell whether it is using the java version or the Graal binary?

@ChadKillingsworth
Copy link
Collaborator

ChadKillingsworth commented Apr 12, 2022

Add the --platform=native flag to the command to guarantee it.

If we think it's Graal, we can use the nightly builds to find out when it was first introduced:

npx google-closure-compiler@20220412.0.0-nightly --platform=native...

https://www.npmjs.com/package/google-closure-compiler (look at the versions tab)

@noppa
Copy link

noppa commented Apr 16, 2022

I created a minimal reproducible example of this using Docker: noppa/google-closure-compiler-npm-issue234-mre

Everything works fine with Ubuntu as the base image, but fails with Arch Linux

@ChadKillingsworth
Copy link
Collaborator

It's going to be challenging to figure out what is causing this. This feels less like an issue with the binary and more that a system library of some sort is missing.

@noppa
Copy link

noppa commented Apr 16, 2022

I tested an old version (2022-01-01) of google-closure-compiler and it still errored. I'm pretty sure I've successfully used a later version of the library on Arch so, like @ChadKillingsworth suspected, it's probably not an issue in a version of google-closure-compiler but rather the platform.

So I did a little experiment with git bisect that uses Arch Linux Archive to install packages from an archive of a specific date between today and 2022-03-01.

Turns out 2022-03-30 is the first date whose archives reproduce this error. Installing packages from 03-29 first and then upgrading to archives of 03-30 shows that the changed packages are (drum roll... 🥁)

Package (2)      Old Version  New Version  Net Change  Download Size

core/libarchive  3.6.0-1      3.6.0-2        0.00 MiB       0.50 MiB
core/zlib        1:1.2.11-5   1:1.2.12-1     0.00 MiB       0.09 MiB

Given that the error message is a ZipException, this seems like pretty damning evidence that one of these two package updates is the culprit.

Zlib changelog is here and the libarchive release is here.

Edit: Actually, there seems to already be several issues of the 1.2.12 build in zlib issues, both Java-related and not.

@noppa
Copy link

noppa commented Apr 16, 2022

Yeah, looks like it's probably madler/zlib#426

@ChadKillingsworth
Copy link
Collaborator

It looks more related to madler/zlib#613.

Nice find btw. Since this is clearly not closure-compiler at this point, I'm going to close the issue.

@noppa
Copy link

noppa commented Apr 17, 2022

If any of the Arch users here want to get things working right away without waiting for the next release of zlib, you can manually rebuild the package with this zlib patch applied to it:

git clone -b packages/zlib --depth 1 https://github.com/archlinux/svntogit-packages.git
cd svntogit-packages/trunk
curl -O https://github.com/madler/zlib/commit/ec3df00224d4b396e2ac6586ab5d25f673caa4c2.patch
curl -o- https://gist.githubusercontent.com/noppa/cb606d86b458ee30b7da8cd73c143a18/raw/6ac6e3faf12d06fc85bab105ade59c55214a76c0/zlib-PKGBUILD.patch | git apply
gpg --recv-key 783FCD8E58BCAFBA
makepkg --clean --syncdeps --rmdeps
sudo pacman -U zlib-1:1.2.12-1-x86_64.pkg.tar.zst

After running these, google-closure-compiler should work normally again.

@robertfirek
Copy link
Author

Thank you all for your help.

It is a problem with zlib library. I installed the old version of the library (1.2.11-5) and the problem disappeared. I think I will wait for the next release of zlib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants