zlib 1.2.13 (and patched 1.2.11) breaks libxml2 on s390x

Bug #2002511 reported by Frank Heimes
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu on IBM z Systems
In Progress
High
Unassigned
zlib
Fix Released
Undecided
zlib (Ubuntu)
Fix Released
High
Unassigned
Focal
New
Undecided
Unassigned
Jammy
New
Undecided
Unassigned
Kinetic
Won't Fix
Undecided
Unassigned
Lunar
Fix Released
High
Unassigned

Bug Description

SRU Justification:
------------------

[ Impact ]

 * zlib version 1.2.13, as well as patched zlib versions 1.2.11 with
   the patch from LP#1990379, break libxml2 and lxml on s390x.

 * The problem appears during loading a gzipped XML file.

 * Disabling hw compression with 'export DFLTCC=0' solves this,
   hence it's a problem with the hardware acceleration patches DFLTCC.

 * For more info see: https://bugzilla.redhat.com/show_bug.cgi?id=2155328

[ Test Plan ]

 * 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.

[ Where problems could occur ]

 * Since this is limited to s390x and DFLTCC / hw acceleration active,
   any possible problems are limited to such environments.

 * Fix can be broken if the state handling (state->wrap),
   or the states mixed.

 * The translation from stream to parameter block could be broken
   (again due to wrong states) and the inflate as well.

[ Other Info ]

 * The official upstream fix is here:
   https://github.com/zlib-ng/zlib-ng/pull/1390
   but it's for zlib-ng.

 * For zlib this needs to be adjusted and was done by the author here:
   https://launchpadlibrarian.net/641454325/patch-1.2.11

 * And again slightly adjusted by me (renamed, some white-space fixes
   and conversion into a quilt patch with proper dep3 header):
   https://launchpadlibrarian.net/645435847/1390.patch

 * The zlib version in Focal, Jammy, Kinetic and Lunar are affected.
__________

It has been reported that 1.2.13 as well as the patch from LP#1990379 breaks libxml2 (and libxml) on s390x:
(https://bugzilla.redhat.com/show_bug.cgi?id=2155328). The attached patch should fix the issue.

The upstream author proposed a fix and a new test for zlib-ng (https://github.com/zlib-ng/zlib-ng/pull/1390) in order to detect such breakages in the future.

___

This was initially reported as part of LP#1990379,
especially: https://bugs.launchpad.net/ubuntu/+source/zlib/+bug/1990379/comments/12
but needs a separate LP bug (number) - this one.
___

The proposed patch at https://launchpadlibrarian.net/641454325/patch-1.2.11
needed some tweaks regarding white-spaces, but then applied fine on focal, jammy, kinetic and also 1.2.13, which is what we currently have in lunar-proposed.

Tags: patch s390x
Revision history for this message
In , lbalhar (lbalhar-redhat-bugs) wrote :

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?

Revision history for this message
In , iii (iii-redhat-bugs) wrote :

This must be a problem with the latest hardware compression patches.

export DFLTCC=0

makes the problem go away.

Revision history for this message
In , lbalhar (lbalhar-redhat-bugs) wrote :

Thanks for the info Ilya. Do you know where and how we can fix this?

Revision history for this message
In , mhroncok (mhroncok-redhat-bugs) wrote :

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>

Revision history for this message
In , iii (iii-redhat-bugs) wrote :

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.

Revision history for this message
In , iii (iii-redhat-bugs) wrote :

Created attachment 1934106
patch for zlib 1.2.11

Revision history for this message
In , iii (iii-redhat-bugs) wrote :

Created attachment 1934107
patch for zlib 1.2.13

Revision history for this message
In , iii (iii-redhat-bugs) wrote :

Please try either of the attached patches.

Revision history for this message
In , lbalhar (lbalhar-redhat-bugs) wrote :

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.

Revision history for this message
In , iii (iii-redhat-bugs) wrote :

Created attachment 1934119
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.

Revision history for this message
In , lbalhar (lbalhar-redhat-bugs) wrote :

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

Revision history for this message
In , ljavorsk (ljavorsk-redhat-bugs) wrote :

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 :)

Revision history for this message
In , ljavorsk (ljavorsk-redhat-bugs) wrote :

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.

Revision history for this message
In , iii (iii-redhat-bugs) wrote :

zlib-1.2.13-1.fc38 passes all of my tests. Thanks!

Revision history for this message
In , ljavorsk (ljavorsk-redhat-bugs) wrote :

Sorry, I forgot to bump the release.

The new builds are in the same location now.

Revision history for this message
In , iii (iii-redhat-bugs) wrote :

No problem; zlib-1.2.13-2.fc38 passes all the tests as well.

Revision history for this message
In , lbalhar (lbalhar-redhat-bugs) wrote :

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?

Frank Heimes (fheimes)
summary: - zlib 1.2.13 breaks libxml(2) on s390x
+ zlib 1.2.13 (and patched 1.2.11) breaks libxml(2) on s390x
Changed in ubuntu-z-systems:
importance: Undecided → High
Revision history for this message
Frank Heimes (fheimes) wrote :

Attaching the slightly modified and renamed patch (original is at LP#1990379),
now as quilt patch, with some whitespace adjustments and a proper dep3 header.

Revision history for this message
Frank Heimes (fheimes) wrote :

PPA test builds a ongoing for F, J, K and L at
https://launchpad.net/~fheimes/+archive/ubuntu/lp2002511

Frank Heimes (fheimes)
description: updated
Changed in ubuntu-z-systems:
status: New → Triaged
Changed in zlib (Ubuntu Lunar):
status: New → In Progress
tags: added: patch
Changed in zlib:
importance: Unknown → Undecided
status: Unknown → In Progress
Revision history for this message
In , lbalhar (lbalhar-redhat-bugs) wrote :

It seems that the latest version of zlib fixed the problem we found in lxml. Thanks! I think you can ship it.

Frank Heimes (fheimes)
summary: - zlib 1.2.13 (and patched 1.2.11) breaks libxml(2) on s390x
+ zlib 1.2.13 (and patched 1.2.11) breaks libxml2 on s390x
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "1390.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

Revision history for this message
Frank Heimes (fheimes) wrote :
Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
status: Triaged → In Progress
Revision history for this message
In , ljavorsk (ljavorsk-redhat-bugs) wrote :

The package is in the Fedora Rawhide stable repo.

Changed in zlib:
status: In Progress → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package zlib - 1:1.2.13.dfsg-1ubuntu4

---------------
zlib (1:1.2.13.dfsg-1ubuntu4) lunar; urgency=medium

  * Add d/p/1390.patch to not update strm.adler for raw streams on s390x
    (DFLTCC), otherwise libxml2 gets broken on s390x. LP: #2002511

 -- Frank Heimes <email address hidden> Wed, 11 Jan 2023 18:02:34 +0100

Changed in zlib (Ubuntu Lunar):
status: In Progress → Fix Released
Revision history for this message
In , iii (iii-redhat-bugs) wrote :

Created attachment 1941938
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.

Revision history for this message
In , tstaudt (tstaudt-redhat-bugs) wrote :

Hello Lukas,

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

Revision history for this message
In , ljavorsk (ljavorsk-redhat-bugs) wrote :

Hi Thomas,

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

Revision history for this message
In , tstaudt (tstaudt-redhat-bugs) wrote :

Thanks, Lukas

Revision history for this message
Utkarsh Gupta (utkarsh) wrote :

Ubuntu 22.10 (Kinetic Kudu) has reached end of life, so this bug will not be fixed for that specific release.

Changed in zlib (Ubuntu Kinetic):
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.