Bug 2280757

Summary: zlibng produces different results in openjdk compressed files
Product: [Fedora] Fedora Reporter: Antonio Vieiro <avieirov>
Component: zlib-ngAssignee: Tulio Magno Quites Machado Filho <tuliom>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 40CC: aekoroglu, code, ljavorsk, tuliom
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-05-16 09:16:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
The "pack200 --repack golden.jar" when pack200 is not using zlibng
none
The "pack200 --repack golden.jar" when pack200 is using zlibng
none
The result of "zipdump" on the bundled generated .jar file.
none
The result of "zipdump" on the system generated jar file.
none
Comparing zipdump generated files with diff zipdump-bundled.txt zipdump-system.txt > zip-diffs.txt none

Description Antonio Vieiro 2024-05-16 08:35:57 UTC
java-11-openjdk in Fedora 40 is built with the `--with-zlib=bundled` flag, meaning that is uses OpenJDK's internal zlib library, and not zlibng.

Trying to build java-11-openjdk with the `--with-zlib=system`n fails on some zip and pack200 tests.

Also any other OpenJDK 11 binary (Amazon Corretto JDK11, for instance) which has been built with the `--with-zlib=system` flag (and that is using zlibng) will generate "jar" and "pack200" tools that behave differently, producing corrupted files.


Reproducible: Always

Steps to Reproduce:
Option 1:
1. Build OpenJDK at https://github.com/openjdk/jdk11 following instructions at https://github.com/openjdk/jdk11/blob/master/doc/building.md
2. Run "make run-test-tier1"

Option 2:
1. Install the "java-11-openjdk" bundled with Fedora (built using --with-zlib=bundled)
2. Install a Java 11 OpenJDK compiled using --with-zlib=system, such as Amazon Corretto [1]
3. Download the "golden.jar" file using in the Pack200 test from [2] to "golden-bundled.jar" and "golden-system.jar"
3.1. curl -L https://github.com/openjdk/jdk11/raw/master/test/jdk/tools/pack200/pack200-verifier/data/golden.jar -o golden-bundled.jar
3.2. curl -L https://github.com/openjdk/jdk11/raw/master/test/jdk/tools/pack200/pack200-verifier/data/golden.jar -o golden-system.jar
4. Repack "golden-bundled.jar" with /usr/lib/jvm/java-11-openjdk-11.0.23.0.9-1.fc40.x86_64/bin/pack200 --repack golden-bundled.jar 
5. Repack "golden-system.jar" with third-party OpenJDK11 /path/to/amazon-corretto-11/bin/pack200 --repack golden-system.jar
6. The two files differ in size:

445677 may 16 10:31 golden-bundled.jar
448934 may 16 10:30 golden-system.jar






[1] https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html
[2] https://github.com/openjdk/jdk11/raw/master/test/jdk/tools/pack200/pack200-verifier/data/golden.jar
Actual Results:  
- OpenJDK 11 does not build on Fedora 40 without the "--with-zlib=bundled"
- Java's "jar" and "pack200" in different OpenJDK versions produce different results.

Expected Results:  
- OpenJDK 11 should build on Fedora 40 with the "--with-zlib=system" configure option.
- All Java runtimes from different vendors should work the same in Fedora 40.

Comment 1 Antonio Vieiro 2024-05-16 08:53:14 UTC
Created attachment 2033505 [details]
The "pack200 --repack golden.jar" when pack200 is not using zlibng

Comment 2 Antonio Vieiro 2024-05-16 08:53:44 UTC
Created attachment 2033506 [details]
The "pack200 --repack golden.jar" when pack200 is using zlibng

Comment 3 Antonio Vieiro 2024-05-16 09:13:59 UTC
Created attachment 2033507 [details]
The result of "zipdump" on the bundled generated .jar file.

Comment 4 Antonio Vieiro 2024-05-16 09:14:39 UTC
Created attachment 2033508 [details]
The result of "zipdump" on the system generated jar file.

Comment 5 Antonio Vieiro 2024-05-16 09:15:16 UTC
Created attachment 2033509 [details]
Comparing zipdump generated files with diff zipdump-bundled.txt zipdump-system.txt > zip-diffs.txt

Comment 6 Antonio Vieiro 2024-05-16 09:16:53 UTC
After some research the bug is not generated by zlibng. It's just that zlibng compresses entries with different ratios than zlib.

The tests in the OpenJDK should be updated to not take into account the sizes of the generated files instead.

Apologies for the noise!