Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6708 Discussions

IPPs deflate goes into infinite loop for file size >= 2GB

mickaelpic
Beginner
600 Views

Hi, I am compressing a file of size 2GB using deflate with Z_NO_FLUSH.
When deflate has processed 2GB (minus 2 bytes) it will go into infinite loop.
Because the avail_in is always equal 2

I have tried with any file size >= 2GB and the problem always occurs.
Any file size < 2GB is working perfectly.

I am using the following code:

#define bufferSize 65536 // 64KB
#define aesBlkSize 32

inBuffer = (unsigned char*)ippMalloc(bufferSize);
if(inBuffer == NULL)
{
printf("Failed to initialize inBuffer ");
return -1;
}
outBuffer = (unsigned char*)ippMalloc(bufferSize);
if(outBuffer == NULL)
{
printf("Failed to initialize outBuffer ");
return -1;
}
stream.next_in = inBuffer;
stream.next_out = outBuffer;
stream.avail_out = bufferSize;
stream.avail_in = 0;
int toWrite = 0;
do
{
len = (unsigned long)fread((char*)inBuffer, 1, bufferSize, fin);
stream.avail_in = len;
if(len > 0)
{
stream.next_in = inBuffer;

do
{
//LOOPING INFINITLY HERE

err = deflate(&stream, Z_NO_FLUSH);
if(err == Z_OK)
{
if(stream.avail_out < bufferSize)
{
toWrite = bufferSize - stream.avail_out;
// write the buffer
if(fwrite((char*)outBuffer, 1, toWrite, fout) != toWrite)
{
printf("Failed to write to file ");
return -1;
  ;}
stream.avail_out = bufferSize;
stream.next_out = outBuffer;
}
}
else
{
if(Check_Error(err, "deflate") == -1)
{
return -1;
}
}
}
while(stream.avail_in != 0);
}
}
while(len != 0);
do
{
err = deflate(&stream, Z_FINISH);
if(err == Z_OK || err == Z_STREAM_END)
{
// write the buffer
if(fwrite((char*)outBuffer, 1, stream.total_out, fout) != stream.total_out)
{
printf("Failed to write to file ");
return -1;
}
stream.avail_out = bufferSize;
stream.next_out = outBuffer;

}
else
{
// Error
if(Check_Error(err, "Z_FINISH") == -1)
{
return -1;
}
}
}
while(err != Z_STREAM_END);
err = deflateEnd(&stream);
if(Check_Error(err, "deflateEnd") == -1)
{
return -1;
}

0 Kudos
2 Replies
Vladimir_Dudnik
Employee
600 Views

Hello,

Please specify IPP version, operating system and host processor architecture for the system where you met that issue.

Regards
Vladimir

0 Kudos
VipinKumar_E_Intel
600 Views

This has been fixed in IPP 6.0 beta.

0 Kudos
Reply