RFR: 8299748: java/util/zip/Deinflate.java failing on s390x
Alan Bateman
alanb at openjdk.org
Tue Feb 7 07:10:46 UTC 2023
On Thu, 2 Feb 2023 10:06:23 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>>> level:1, strategy: 0, dowrap: false
>>> is finished: false
>>
>> Thanks for checking that. So "is finished: false" is telling us that not all of the input was compressed. So I think the right thing is to do the deflate in a loop until there is more input to compress, the inflate probably needs the same. Your original proposal was to make the output buffer larger and I suspect that is just working around a threshold or block size used by the accelerator.
>
>> Hi @AlanBateman ,
>> with latest changes (doing inflate/deinflate) test passes over s390 and x86 as well. Please take a look now.
>
> Good. One thing to try is to just deflate/inflate into out1/out2, no need for the intermediate BAOS, try this:
>
>
> --- a/test/jdk/java/util/zip/DeInflate.java
> +++ b/test/jdk/java/util/zip/DeInflate.java
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> *
> * This code is free software; you can redistribute it and/or modify it
> @@ -127,11 +127,25 @@ public class DeInflate {
>
> def.setInput(in, 0, len);
> def.finish();
> - int m = def.deflate(out1);
> + int m = 0;
> + while (!def.finished()) {
> + int remaining = out1.length - m;
> + if (remaining == 0) {
> + throw new RuntimeException("out1 is small");
> + }
> + m += def.deflate(out1, m, remaining);
> + }
>
> Inflater inf = new Inflater(nowrap);
> inf.setInput(out1, 0, m);
> - int n = inf.inflate(out2);
> + int n = 0;
> + while (!inf.finished()) {
> + int remaining = out2.length - n;
> + if (remaining == 0) {
> + throw new RuntimeException("out2 is small");
> + }
> + n += inf.inflate(out2, n, remaining);
> + }
>
> if (n != len ||
> !Arrays.equals(Arrays.copyOf(in, len), Arrays.copyOf(out2, len)) ||
> @AlanBateman should we proceed with the current changes then ?
The BAOS in your current proposal shouldn't be needed so I suspect there is something else "interesting" with this zlib implementation. For the patch above, can you remove the checking for remaining == 0 and print out the value from deflate at each iterate of the loop. I'm wondering if it returns 0 before def.finished() returns true.
-------------
PR: https://git.openjdk.org/jdk/pull/12283
More information about the core-libs-dev
mailing list