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

Builds broken - July 19, 2023 #3174

Closed
iBotPeaches opened this issue Jul 19, 2023 · 8 comments · Fixed by #3178
Closed

Builds broken - July 19, 2023 #3174

iBotPeaches opened this issue Jul 19, 2023 · 8 comments · Fixed by #3178

Comments

@iBotPeaches
Copy link
Owner

Somehow builds are all failing, even old ones.

https://github.com/iBotPeaches/Apktool/actions/runs/5586823977/jobs/10238074452

brut.androlib.aapt1.SharedLibraryTest > isSharedResourceDecodingAndRebuildingWorking FAILED
    brut.androlib.exceptions.AndrolibException: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
        at app//brut.androlib.res.Framework.installFramework(Framework.java:105)
        at app//brut.androlib.res.Framework.installFramework(Framework.java:49)
        at app//brut.androlib.aapt1.SharedLibraryTest.isSharedResourceDecodingAndRebuildingWorking(SharedLibraryTest.java:86)

        Caused by:
        java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
            at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1728)
            at java.base/java.util.zip.ZipFile$Source.checkExtraFields(ZipFile.java:1261)
            at java.base/java.util.zip.ZipFile$Source.checkAndAddEntry(ZipFile.java:1212)
            at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1667)
            at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1445)
            at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1407)
            at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:716)
            at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:250)
            at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:179)
            at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:193)
            at brut.androlib.res.Framework.installFramework(Framework.java:57)
            ... 2 more
@iBotPeaches
Copy link
Owner Author

Looks like JDK 11 & 17 failed

@iBotPeaches
Copy link
Owner Author

This is escaping me. I've got no idea at present. I've:

Nothing is adding up

@evowizz
Copy link

evowizz commented Jul 19, 2023

I was able to reproduce the issue locally. It is indeed caused by JDK 17.0.8.

The following is mentioned in the changelog:

Improved ZIP64 Extra Field Validation (JDK-8302483 (not public))

java.util.zip.ZipFile has been updated to provide additional validation of ZIP64 extra fields when opening a ZIP file. This validation may be disabled by setting the system property jdk.util.zip.disableZip64ExtraFieldValidation to true.

The tests passed after using the system property within the test block in build.gradle:

    test {
        systemProperty 'jdk.util.zip.disableZip64ExtraFieldValidation', 'true'

        testLogging {
            exceptionFormat = 'full'
        }
    }

Not sure what would be the next step from there. But I hope this helps!

@iBotPeaches
Copy link
Owner Author

thanks @evowizz - that is indeed it. Thanks for your tip/help

aarongable pushed a commit to chromium/chromium that referenced this issue Jul 21, 2023
JDK 20 was causing issues for codesearch.

Includes a work-around (added jvm flag) to disable an exception
about invalid zip file headers. Found this via:
iBotPeaches/Apktool#3174 (comment)


Bug: b/291804782
Change-Id: I743664ace22c035a6957b46a4df9918cedb59ef9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4705883
Commit-Queue: Sam Maier <smaier@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Sam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1173508}
zeng450026937 pushed a commit to zeng450026937/build that referenced this issue Jul 24, 2023
JDK 20 was causing issues for codesearch.

Includes a work-around (added jvm flag) to disable an exception
about invalid zip file headers. Found this via:
iBotPeaches/Apktool#3174 (comment)

Bug: b/291804782
Change-Id: I743664ace22c035a6957b46a4df9918cedb59ef9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4705883
Commit-Queue: Sam Maier <smaier@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Sam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1173508}
NOKEYCHECK=True
GitOrigin-RevId: edddc72945918f04458ef0c556f22753069ca18e
@jpstotz
Copy link

jpstotz commented Jul 27, 2023

Just a note: calling System.setProperty("jdk.util.zip.disableZip64ExtraFieldValidation", "true"); is useless, even if you call it in a static { } block in the main class:

The Java developers were so "intelligent" to check this property at load-time of java.util.zip.ZipFile and copy it's value into a private static field:

    private static final boolean disableZip64ExtraFieldValidation =
            GetBooleanAction.privilegedGetProperty("jdk.util.zip.disableZip64ExtraFieldValidation");

As the Java class loaders use ZIPFile class to load the Jar files from class path, ZipFile class is loaded long before any user created class respectively the main class is loaded. Therefore I don't see a way how a call to System.setProperty("jdk.util.zip.disableZip64ExtraFieldValidation", "true"); will ever have any effect in a Java program. From my perspective the only way to set this property is from "outside", thus on the java command-line.

This affects all users who directly execute aktool from command-line. For exemple if you execute apktool 2.8.1 on library.apk

java -jar apktool_2.8.1.jar d library.apk

You will still run into ZipException: Invalid CEN header (invalid zip64 extra data field size).
I would really like to know which OpenJDK developer is responsible for this nonsense...

@iBotPeaches
Copy link
Owner Author

thanks @jpstotz. Here is the commit I tracked down when I was researching this. openjdk/jdk@fff7e1a

jrguzman-ms pushed a commit to msft-mirror-aosp/platform.external.libchrome that referenced this issue Jul 27, 2023
JDK 20 was causing issues for codesearch.

Includes a work-around (added jvm flag) to disable an exception
about invalid zip file headers. Found this via:
iBotPeaches/Apktool#3174 (comment)


Bug: b/291804782
Change-Id: I743664ace22c035a6957b46a4df9918cedb59ef9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4705883
Commit-Queue: Sam Maier <smaier@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Sam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1173508}


CrOS-Libchrome-Original-Commit: edddc72945918f04458ef0c556f22753069ca18e
@amir169
Copy link

amir169 commented Jul 30, 2023

I was able to reproduce the issue locally. It is indeed caused by JDK 17.0.8.

The following is mentioned in the changelog:

Improved ZIP64 Extra Field Validation (JDK-8302483 (not public))
java.util.zip.ZipFile has been updated to provide additional validation of ZIP64 extra fields when opening a ZIP file. This validation may be disabled by setting the system property jdk.util.zip.disableZip64ExtraFieldValidation to true.

The tests passed after using the system property within the test block in build.gradle:

    test {
        systemProperty 'jdk.util.zip.disableZip64ExtraFieldValidation', 'true'

        testLogging {
            exceptionFormat = 'full'
        }
    }

Not sure what would be the next step from there. But I hope this helps!

I'm having the same problem in another project. My question is if it should be the way to solve the problem. I mean did they add an extra validation in new JDK for us to disable?

@jeromew
Copy link

jeromew commented Oct 9, 2023

This affects all users who directly execute aktool from command-line. For exemple if you execute apktool 2.8.1 on library.apk

java -jar apktool_2.8.1.jar d library.apk

You will still run into ZipException: Invalid CEN header (invalid zip64 extra data field size). I would really like to know which OpenJDK developer is responsible for this nonsense...

I am not familiar with java but I thought it could be interesting for people hitting this issue on the command line to know that the following workaround works

JAVA_TOOL_OPTIONS="-Djdk.util.zip.disableZip64ExtraFieldValidation=true" java -jar apktool_2.9.0.jar d library.apk

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

Successfully merging a pull request may close this issue.

5 participants