RFR: 8299748: java/util/zip/Deinflate.java failing on s390x

Alan Bateman alanb at openjdk.org
Thu Feb 2 10:09:04 UTC 2023


On Wed, 1 Feb 2023 08:46:12 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Hi Alan, here is output: 
>> 
>> level:0, strategy: 2, dowrap: true                                                                                                
>> is finished: true                                                
>> is finished: true
>> is finished: true
>> is finished: true                                                                                                                 is finished: true
>> level:1, strategy: 0, dowrap: false               
>> is finished: false     
>> m=525312, n=497972, len=524288, eq=false                                                                                          STDERR:    
>> java.lang.RuntimeException: De/inflater failed:java.util.zip.Deflater at 23a0858b                                               
>> 
>> 
>> 
>> But I guess this behaviour could be explained (by zEDC). On s390x, there is additional instruction present and it could be enabled by setting `DFLTCC=1`. And for accelerator the size of compressed data could go`2 times` the size of actual data. Again this is not deterministic as well, i.e. for same data there could be different valid deflate stream.
>
>> 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)) ||

-------------

PR: https://git.openjdk.org/jdk/pull/12283


More information about the core-libs-dev mailing list