Menu

#1156 zlibCompressionTest loops endlessly

3.0 Alpha Series
open
nobody
None
5
2016-11-25
2016-08-27
f0rt
No

I noticed that the zlibCompressionTest loops endlessly in case r is set to 0x3dd0def3 in the randData method of the CompressionTest class.

In this case the decompress method of the CompressionTest class does not get a Z_STREAM_END (=1) from the inflate function (Source/zlib/INFBLOCK.C).

I run scons test-code (as described below) on subversion revision 6782 with the following change of Source/Tests/compression.cpp.

Index: Source/Tests/compression.cpp
===================================================================
--- Source/Tests/compression.cpp    (revision 6782)
+++ Source/Tests/compression.cpp    (working copy)
@@ -18,7 +18,7 @@
     srand(time(0));

     for (int i = 0; i < kb; i++) {
-      int r = rand();
+      int r = 0x3dd0def3 /* rand() */;
       for (size_t j = 0; j < 1024/sizeof(int); j++) {
         buf.add(&r, sizeof(int));
       }
scons UNICODE=yes SKIPUTILS=zip2exe test-code

Discussion

  • Amir Szekely

    Amir Szekely - 2016-08-27

    That might explain why drone.io builds sometimes hang on that step. Do you have any idea why this is happening?

     
  • f0rt

    f0rt - 2016-08-28

    I enabled the traces in the INFBLOCK.C source file and set a break point at the inflate_flush function.

    Index: Source/zlib/INFBLOCK.C
    ===================================================================
    --- Source/zlib/INFBLOCK.C  (revision 6782)
    +++ Source/zlib/INFBLOCK.C  (working copy)
    @@ -20,6 +20,12 @@
    
     #include "ZUTIL.H"
    
    +#ifdef Tracev
    +#include <stdio.h>
    +#undef Tracev
    +#define Tracev(x) fprintf x
    +#endif
    +
     #ifndef min
     #  define min(x,y) ((x<y)?x:y)
     #endif
    @@ -689,8 +695,8 @@
             LEAVE(Z_OK)
           if (s->mode == CODES_WASH)
           {
    -        Tracev((stderr, _T("inflate:       codes end, %lu total out\n"),
    -               z->total_out + (q >= s->read ? q - s->read :
    +        Tracev((stderr, _T("inflate:       codes end, %lu out\n"),
    +               (q >= s->read ? q - s->read :
                    (s->end - s->read) + (q - s->window))));
           }
           /* DRY if last, TYPE if not */
    

    Only the following trace was received:

    inflate:     fixed codes block (last)
    

    For each iteration the inflate function returned Z_OK via the macro NEEDBITS (->NEEDBYTE->LEAVE(Z_OK)->UPDATE->inflate_flush->return Z_OK) in line 596.

     
  • Anders

    Anders - 2016-11-25

    I have not been able to figure out what the exact pattern is but it has something to do with setting the top bit in a byte, possibly just the low byte.

    --------100100001001000010000000 0x--909080
    --------100100001010000010010000 0x--90a090
    --------101000001001000010010000 0x--a09090
    --111101110100001101111011110011 0x3dd0def3
    10010000000000001001000010010000 0x90009090
    10010000100100000000000010010000 0x90900090
    ?0000000?0000000?000000010000000 MASK
    
     

Log in to post a comment.