Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, August 2006
qCompress crash


Message 1 in thread

Hello,

I am using qCompress in my application and detect a crash in qCompress 
when using it a lot.

Attached a code sample that reproduce the issue.

The application was compiled using msvc-7.1.

I use the application with following parameters, and the access 
violation appear during the third compression.

Try to compress 10 times 500000000 bytes:
    qCompress.exe 10 500000000

output:
    --> Compressing 500000000 bytes...
    --> Compressed fine. Compressed size: 485999
    --> Compressed fine. Compressed size: 485999
    --> CRASH...

The crash appear all the time, but with different parameters according 
to computer configuration.
So fill free to use different parameters in order to reproduce the issue.

Could someone try my sample and report me the result please.

Thanks

Templie Cédric

#include <stdlib.h>
#include <stdlib.h>

#include <QtCore/QByteArray>
#include <QtCore/QList>

void main( int argc, char *argv[] )
{
	// The number of the passes to perform
	int tasksNumber = 0;
	// The the size of the buffer that should be generated
	int taskSize = 1024; 
	
	// check if no parameters were passed
	if( argc == 1 )
	{
		qDebug( "Pass the task number and size" ); 
		return; 
	}
	
	// get the command line parameter which indicates the number of tasks to be created
	if( argc > 1 )
	{
		char* parameter = argv[1]; 
		tasksNumber = atoi(parameter); 
	}

	// get the command line parameter which indicates the size of the task that should be generated
	if( argc > 2 )
	{
		char* parameter = argv[2]; 
		taskSize = atoi( parameter ); 
	}
	
	// the list to store compressed QByteArrays
	QList<QByteArray> compressedArrayList; 

	// buffers to store the plain data
	QByteArray uncompressedData; 
	// create the message of needed size
	uncompressedData.fill( 'd', taskSize ); 
	// check the generated byte array
	if( !uncompressedData.isEmpty() )
	{
		qDebug( "Compressing %d bytes...", uncompressedData.size() ); 
		
		// generate the needed number of byte arays
		while( tasksNumber )
		{
			// the compressed data which should be decompressed
			QByteArray compressedData; 
			// compress it
			compressedData = qCompress( uncompressedData ); 
			
			// put the array in the list
			compressedArrayList << compressedData; 
			// check the result
			if( !compressedData.isEmpty() )
			{
				qDebug( "Compressed fine. Compressed size: %d", compressedData.size() ); 
			}
			else
			{
				qDebug( "Error: Compress failed!" ); 
			}
			// decrement the tasks number that is left to perform
			tasksNumber--; 
		}
	}
	else
	{
		qDebug( "Error: plain data could not be generated!" ); 
	}

	qDebug( "All tasks generated." ); 
	
}

Message 2 in thread

I forgot to mention that I use Qt 4.1.4

Templie Cédric

--
 [ signature omitted ] 

Message 3 in thread

On Thursday 17 August 2006 08:54, Templie Cédric wrote:
> I am using qCompress in my application and detect a crash in qCompress
> when using it a lot.

I can reproduce the crash on Linux. Here's a backtrace:

#0  0x00346ecc in deflateParams () from /usr/lib/libz.so.1
No symbol table info available.
#1  0x00345fd0 in deflate () from /usr/lib/libz.so.1
No symbol table info available.
#2  0x00343bd7 in compress2 () from /usr/lib/libz.so.1
No symbol table info available.
#3  0x009f2554 in qCompress (data=0x97f7f018 'd' <repeats 200 times>..., nbytes=500000000,
    compressionLevel=-1) at tools/qbytearray.cpp:373
        len = 505000013
        bazip = {static shared_null = {ref = {atomic = 2}, alloc = 0, size = 0,
    data = 0x804a560 "", array = ""}, static shared_empty = {ref = {atomic = 1}, alloc = 0,
    size = 0, data = 0xb5a238 "", array = ""}, d = 0x97e00470}
        res = 134516552
#4  0x08048d97 in qCompress (data=@0xbfc86014, compressionLevel=-1)
    at /gel/culbute/usr/perreaul//include/QtCore/qbytearray.h:507
No locals.
#5  0x080489f9 in main (argc=3, argv=0xbfc860d4) at qCompressTest.cpp:52
        compressedData = {static shared_null = {ref = {atomic = 2}, alloc = 0, size = 0,
    data = 0x804a560 "", array = ""}, static shared_empty = {ref = {atomic = 1}, alloc = 0,
    size = 0, data = 0xb5a238 "", array = ""}, d = 0x804a550}
        tasksNumber = 6
        taskSize = 500000000
        compressedArrayList = {{p = {static shared_null = {ref = {atomic = 2}, alloc = 0,
        begin = 0, end = 0, sharable = 1, array = {0x0}}, d = 0x8fab0f0}, d = 0x8fab0f0}}
        uncompressedData = {static shared_null = {ref = {atomic = 2}, alloc = 0, size = 0,
    data = 0x804a560 "", array = ""}, static shared_empty = {ref = {atomic = 1}, alloc = 0,
    size = 0, data = 0xb5a238 "", array = ""}, d = 0x97f7f008}

--
 [ signature omitted ] 

Message 4 in thread

Templie Cédric wrote:
> Hello,
> 
> I am using qCompress in my application and detect a crash in qCompress
> when using it a lot.
> 
> Attached a code sample that reproduce the issue.
> 
> The application was compiled using msvc-7.1.
> 
> I use the application with following parameters, and the access
> violation appear during the third compression.
> 
> Try to compress 10 times 500000000 bytes:
>    qCompress.exe 10 500000000
> 
> output:
>    --> Compressing 500000000 bytes...
>    --> Compressed fine. Compressed size: 485999
>    --> Compressed fine. Compressed size: 485999
>    --> CRASH...
> 
> The crash appear all the time, but with different parameters according
> to computer configuration.
> So fill free to use different parameters in order to reproduce the issue.
> 
> Could someone try my sample and report me the result please.

This is on Linux with system libz, not the one bundled. With the Qt 4.2
preview I also get a crash, but in Qt not libz like Simon

Program terminated with signal 11, Segmentation fault.
#0  0xa74b46db in QBasicAtomic::init (this=0x0, x=1) at
../../include/QtCore/../../src/corelib/thread/qatomic.h:66
66          { atomic = x; }
(gdb) bt
#0  0xa74b46db in QBasicAtomic::init (this=0x0, x=1) at
../../include/QtCore/../../src/corelib/thread/qatomic.h:66
#1  0xa74b9865 in QByteArray::resize (this=0xafa3af84, size=505000017)
at tools/qbytearray.cpp:1296
#2  0xa74bb04d in qCompress (data=0x89486018 'd' <repeats 200 times>...,
nbytes=500000000, compressionLevel=-1) at tools/qbytearray.cpp:370
#3  0x08048d97 in qCompress (data=@0xafa3b014, compressionLevel=-1)
    at
/home/adamm/work/src/qt/qt-x11-preview-commercial-src-4.2.0-tp1/include/QtCore/../../src/corelib/tools/qbytearray.h:505
#4  0x080489f9 in main (argc=3, argv=0xafa3b0c4) at t.cpp:52


t.cpp:52 is the qCompress line.

- Adam

--
 [ signature omitted ]