Hi,

So spent some time with this bugs and will go through them one by one.

First CloseInflaterDeflaterTest.java i'll follow up with the other
tests.

# TLDR
disable the TESTCASE on s390x but leave the DLFTCC hardware compression enabled.

# Problem:
the tests is built on the assumption that the zlib-deflate parameter Z_NO_FLUSH 
in combination an input buffer of 512 bytes will actually not generate any 
output on the first call. However the hardware compressor will always compress 
data and generate data for the output stream. This is an allowed behavior in 
zlib[3].

This means that most testcases will run much earlier into an
IOException[1] or a NullPointerException[2] as the software
implementation and therefor fail the testcases.


# Solutions:

- deactivate this tests on s390x: 
    The behavior of the openjdk zlib connection is tested on other platforms. 
The tests where originally intended to test if openjdk will correctly close a 
stream in case it cannot flush the output. This functionality is actually the 
same on all architectures.

- Fix the tests for s390x:
    This is not trivial as one needs to adapt input buffers and catch different 
exceptions for different architectures.


# Traces:

here the calls the tests does to deflate for a 512byte input:

## with hardware compression DISABLED
```
-->(deflate) args(flush(0) strm (
                        ->avail_in(512)
                        ->avail_out(512)
                        ->total_in(0)
                        ->total_out(0)
                        ->state->status(42)
                        ->state->pending(0))
<--(deflate) retval(0x0) strn (
                        ->avail_in(0)
                        ->avail_out(510)
                        ->total_in(512)
                        ->total_out(2)
                        ->state->status(113)
                        ->state->pending(0))
-->(deflate) args(flush(4) strm (
                        ->avail_in(0)
                        ->avail_out(512)
                        ->total_in(512)
                        ->total_out(2)
                        ->state->status(113)
                        ->state->pending(0))
<--(deflate) retval(0x0) strn (
                        ->avail_in(0)
                        ->avail_out(0)
                        ->total_in(512)
                        ->total_out(514)
                        ->state->status(666)
                        ->state->pending(5))
-->(deflate) args(flush(4) strm (
                        ->avail_in(0)
                        ->avail_out(512)
                        ->total_in(512)
                        ->total_out(514)
                        ->state->status(666)
                        ->state->pending(5))
<--(deflate) retval(0x1) strn (
                        ->avail_in(0)
                        ->avail_out(503)
                        ->total_in(512)
                        ->total_out(523)
                        ->state->status(666)
                        ->state->pending(0))

```
the first calls sets flush(0)(Z_NO_FLUSH). then sets flush(4)(Z_FINISH) and 
needs a total of 3 calls to deflate until it finally gets a return of 
1(Z_STREAM_END).


## with hardware compression ENABLED
```
-->(deflate) args(flush(0) strm (
                        ->avail_in(512)
                        ->avail_out(512)
                        ->total_in(0)
                        ->total_out(0)
                        ->state->status(42)
                        ->state->pending(0))
<--(deflate) retval(0x0) strn (
                        ->avail_in(25)
                        ->avail_out(0)
                        ->total_in(487)
                        ->total_out(512)
                        ->state->status(113)
                        ->state->pending(0))
-->(deflate) args(flush(4) strm (
                        ->avail_in(25)
                        ->avail_out(512)
                        ->total_in(487)
                        ->total_out(512)
                        ->state->status(113)
                        ->state->pending(0))
<--(deflate) retval(0x1) strn (
                        ->avail_in(0)
                        ->avail_out(476)
                        ->total_in(512)
                        ->total_out(548)
                        ->state->status(666)
                        ->state->pending(0))
```
even through the first call has flush(0) set we see ->total_out(512) when it 
returns. After the next call with flush(4)(Z_STREAM_END), zlib will immediately 
flush out the rest, finish up the output stream and return Z_STREAM_END.


 
[1] 
https://github.com/openjdk/jdk/blob/master/test/jdk/java/util/zip/CloseInflaterDeflaterTest.java#L54
[2] 
https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/zip/DeflaterOutputStream.java#L124
[3] https://github.com/madler/zlib/blob/develop/zlib.h#L286-L288

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2109016

Title:
  openjdk regressions on s390x with hardware-accelerated
  compress/decompress

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-z-systems/+bug/2109016/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to