Bug 2155328

Summary: zlib 1.2.13 breaks libxml2 and lxml on s390x
Product: [Fedora] Fedora Reporter: Lumír Balhar <lbalhar>
Component: zlibAssignee: Lukas Javorsky <ljavorsk>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: iii, jchaloup, ljavorsk, mhroncok, mmuzila, odubaj, pkubat, praiskup, tstaudt
Target Milestone: ---   
Target Release: ---   
Hardware: s390x   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-01-13 10:36:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 467765, 2153063    
Attachments:
Description Flags
patch for zlib 1.2.11
none
patch for zlib 1.2.13
none
patch for zlib 1.2.13 (rawhide version)
none
patch for zlib 1.2.11 none

Description Lumír Balhar 2022-12-20 20:39:24 UTC
Description of problem:
The latest version of zlib (1.2.13) in rawhide breaks libxml2 (and therefore lxml). The problem appears during loading a gzipped XML file.

Version-Release number of selected component (if applicable):
zlib-1.2.13-1.fc38.s390x

How reproducible:
Allways.

Steps to Reproduce:
1. echo "<a></a>" > file.xml
2. gzip file.xml
3. python3
>>> import libxml2
>>> libxml2.parseFile("file.xml.gz")

Actual results:
file.xml.gz:1: parser error : Document is empty

^
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.11/site-packages/libxml2.py", line 1362, in parseFile
    if ret is None:raise parserError('xmlParseFile() failed')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
libxml2.parserError: xmlParseFile() failed

Expected results:
Loaded file. It works fine with zlib-1.2.12-5.fc37.s390x.

Additional info:
Might this be caused by the downstream patches we have in Fedora for s390x?

Comment 1 Ilya Leoshkevich 2022-12-21 19:24:28 UTC
This must be a problem with the latest hardware compression patches.

export DFLTCC=0

makes the problem go away.

Comment 2 Lumír Balhar 2022-12-21 22:18:06 UTC
Thanks for the info Ilya. Do you know where and how we can fix this?

Comment 3 Miro Hrončok 2022-12-22 01:30:43 UTC
I can confirm DFLTCC=0 makes the problem go away.

$ python3
..
>>> libxml2.parseFile("file.xml.gz")
file.xml.gz:1: parser error : Document is empty

^
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.11/site-packages/libxml2.py", line 1362, in parseFile
    if ret is None:raise parserError('xmlParseFile() failed')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
libxml2.parserError: xmlParseFile() failed


$ DFLTCC=0 python3
...
>>> libxml2.parseFile("file.xml.gz")
<xmlDoc (file.xml.gz) object at 0x3ff930787d0>

Comment 4 Ilya Leoshkevich 2022-12-22 08:56:14 UTC
Yes, this must be the new strm.adler change - it seems that we should not be updating this field for raw streams.
I am working on a fix.

Comment 5 Ilya Leoshkevich 2022-12-22 11:01:17 UTC
Created attachment 1934106 [details]
patch for zlib 1.2.11

Comment 6 Ilya Leoshkevich 2022-12-22 11:01:39 UTC
Created attachment 1934107 [details]
patch for zlib 1.2.13

Comment 7 Ilya Leoshkevich 2022-12-22 11:10:21 UTC
Please try either of the attached patches.

Comment 8 Lumír Balhar 2022-12-22 14:11:45 UTC
Thanks for the patches. Could one of the package maintainers try it, please? I've tried to apply it and it does not apply. Looking at the patches we already have they depend on each other so I don't know whether I should add this one as a new one or squash it into zlib-1.2.13-IBM-Z-hw-accelerated-deflate.patch which adds the file the new patch tries to modify.

Comment 9 Ilya Leoshkevich 2022-12-22 15:19:13 UTC
Created attachment 1934119 [details]
patch for zlib 1.2.13 (rawhide version)

Hm, indeed, the 1.2.13 patch that I posted did not apply to the rawhide zlib. I generated it against https://github.com/madler/zlib/pull/410#issuecomment-1353070525, which is slightly ahead.

I've attached the rebased version; it should go after all the current rawhide patches, i.e. after Patch23: zlib-1.2.11-covscan-issues-rhel9.patch.

Comment 10 Lumír Balhar 2022-12-23 12:58:53 UTC
I did a test in COPR. With the rawhide version of zlib, python-lxml fails to build because one of the tests loading gzipped XML file fails. With the new patch, python-lxml builds fine. See: https://copr.fedorainfracloud.org/coprs/lbalhar/zlib/builds/

PR for zlib: https://src.fedoraproject.org/rpms/zlib/pull-request/21

Comment 11 Lukas Javorsky 2023-01-09 10:55:40 UTC
I'm working on it.

There are several things that need to be addressed before applying the changes in the patch.

I'm waiting for the rebase of the patch at https://github.com/madler/zlib/pull/410

After that, it should be good to go :)

Comment 12 Lukas Javorsky 2023-01-10 14:13:46 UTC
I've created a test build to address this issue (https://ljavorsk.fedorapeople.org/zlib/zlib-1.2.13-libxml-fix/)

Could you please test it?

Lumir, please test if it fixes your issue, and Ilya, please test if it doesn't break any of your tests.

Thank you for the reports in advance.

Comment 13 Ilya Leoshkevich 2023-01-10 14:18:03 UTC
zlib-1.2.13-1.fc38 passes all of my tests. Thanks!

Comment 14 Lukas Javorsky 2023-01-10 14:32:11 UTC
Sorry, I forgot to bump the release.

The new builds are in the same location now.

Comment 15 Ilya Leoshkevich 2023-01-10 14:34:48 UTC
No problem; zlib-1.2.13-2.fc38 passes all the tests as well.

Comment 16 Lumír Balhar 2023-01-11 10:02:00 UTC
Thanks Lukáši for the fixes. I've tried to contact you on IRC. Could you please upload the SRPM or open a PR with your changes so I can rebuild the new zlib in COPR and test lxml on top of it?

Comment 17 Lumír Balhar 2023-01-11 13:19:58 UTC
It seems that the latest version of zlib fixed the problem we found in lxml. Thanks! I think you can ship it.

Comment 18 Lukas Javorsky 2023-01-13 10:36:54 UTC
The package is in the Fedora Rawhide stable repo.

Comment 19 Ilya Leoshkevich 2023-02-02 23:01:00 UTC
Created attachment 1941938 [details]
patch for zlib 1.2.11

You can also find this patch at https://github.com/iii-i/zlib/commits/crc32vx-v5-1.2.11.

Comment 20 Thomas Staudt 2023-05-11 10:40:40 UTC
Hello Lukas, 

do we need to open a bug to get this into RHEL 9.3 or will this be propagated somehow?
Thanks.

Comment 21 Lukas Javorsky 2023-06-05 07:33:48 UTC
Hi Thomas,

This has been already fixed in RHEL-9.2 (BZ#2166501) which has been shipped already.

Comment 22 Thomas Staudt 2023-06-05 10:10:55 UTC
Thanks, Lukas