Problems with Zlib - data error

Era Scarecrow via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 20 13:19:31 PDT 2017


I took the UnCompress example and tried to make use of it, 
however it breaks midway through my program with nothing more 
than 'Data Error'.

[code]
//shamelessly taken for experimenting with
UnCompress decmp = new UnCompress;
foreach (chunk; stdin.byChunk(4096).map!(x => 
decmp.uncompress(x)))
[/code]

Although 2 things to note. First I'm using an xor block of data 
that's compressed (either with gzip or using only zlib), and 
second the size of the data is 660Mb, while the compressed gzip 
file is about 3Mb in size. So when the data gets out of the large 
null blocks is when it dies. The first 5Mb fits in 18k of 
compressed space (and could be re-compressed to save another 17%).

Is this a bug with zlib? With the Dlang library? Or is it a 
memory issue with allocation (which drove me to use this rather 
than the straight compress/decompress in the first place).

[code]
   File xor = File(args[2], "r"); //line 53

   foreach (chunk; xor.byChunk(2^^16).map!(x => cast(ubyte[]) 
decmp.uncompress(x))) //line 59 where it's breaking, doesn't 
matter if it's 4k, 8k, or 64k.
[/code]


std.zlib.ZlibException at std\zlib.d(96): data error
----------------
0x00407C62 in void std.zlib.UnCompress.error(int)
0x00405134 in ubyte[] 
xortool.main(immutable(char)[][]).__lambda2!(ubyte[]).__lambda2(ubyte[])
0x00405291 in @property ubyte[] 
std.algorithm.iteration.__T9MapResultS297xortool
4mainFAAyaZ9__lambda2TS3std5stdio4File7ByChunkZ.MapResult.front() 
at 
c:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(582)
0x0040243F in _Dmain at g:\\Patch-Datei\xortool.d(59)
0x00405F43 in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x00405F07 in void rt.dmain2._d_run_main(int, char**, extern (C) 
int function(char[][])*).runAll()
0x00405E08 in _d_run_main
0x00405BF8 in main at g:\\Patch-Datei\xortool.d(7)
0x0044E281 in mainCRTStartup
0x764333CA in BaseThreadInitThunk
0x77899ED2 in RtlInitializeExceptionChain
0x77899EA5 in RtlInitializeExceptionChain


More information about the Digitalmars-d-learn mailing list