[Qt-interest] QtConcurrent::run results in random crashes

Justus Best just18 at gmx.de
Tue Jul 27 22:18:39 CEST 2010


Hi,

Can someone here tell me why this :

// non member function which is used by QtConcurrent::run
QPair<QPixmap, QString> createData(QString file, QSize size)
{
	return qMakePair(QPixmap(file).scaled(size), file);
}

ConcurrentTest::ConcurrentTest(QWidget *parent)
     : QWidget(parent)
{
	QStringList list;
	list << "*.tif";
	QString dir = "E:/isas_image/syn_40nm";
	list = QDir(dir).entryList(list);

	for (int i = 0; i < list.size(); i++) {
		list[i] = dir + '/' + list[i];
		QFutureWatcher<QPair<QPixmap, QString> > *watcher =
				new QFutureWatcher<QPair<QPixmap, QString> >(this);
		connect(watcher, SIGNAL(finished()), this, SLOT(processData()));

		QFuture<QPair<QPixmap, QString> > future =
				QtConcurrent::run(createData, list[i], QSize(200,200));
		watcher->setFuture(future);
	}
	qDebug() << "List size: " << list.size();
}

void ConcurrentTest::processData()
{
	static int counter = 0;
	QFutureWatcher<QPair<QPixmap, QString> > *watcher =
			static_cast<QFutureWatcher<QPair<QPixmap, QString> > *>(sender());
	qDebug() << watcher->result().second << " count " << ++counter;
}


This code crashes randomly with following stack
0	RtlpNtEnumerateSubKey	ntdll	0	0x776ffabc	
1	RtlUlonglongByteSwap	ntdll	0	0x776c26c4	
2	RtlValidateHeap	ntdll	0	0x7768e1cf	
3	HeapValidate	KERNELBASE	0	0x7701468e	
4	CrtIsValidHeapPointer	MSVCR90D	0	0x6be01ac9	
5	free_dbg	MSVCR90D	0	0x6be00b3a	
6	free_dbg	MSVCR90D	0	0x6be009e0	
7	free	MSVCR90D	0	0x6be08990	
8	qFree	qmalloc.cpp	60	0x6705ba6d	
9	QHashData::freeNode	qhash.cpp	189	0x6708eb8b	
10 
QHash<QPixmapCache::Key,QCache<QPixmapCache::Key,QPixmapCacheEntry>::Node>::deleteNode 
qhash.h	508	0x651a15d2	
11 
QHash<QPixmapCache::Key,QCache<QPixmapCache::Key,QPixmapCacheEntry>::Node>::remove 
qhash.h	791	0x651a055a	
12	QCache<QPixmapCache::Key,QPixmapCacheEntry>::unlink	qcache.h	75 
0x6519fe31	
13	QCache<QPixmapCache::Key,QPixmapCacheEntry>::trim	qcache.h	210 
0x651a0ba4	
14	QCache<QPixmapCache::Key,QPixmapCacheEntry>::insert	qcache.h	189 
0x6519f6b5	
15	QPMCache::insert	qpixmapcache.cpp	304	0x6519dc47	
16	QPixmapCache::insert	qpixmapcache.cpp	532	0x6519e652	
17	QPixmap::load	qpixmap.cpp	837	0x6519a285	
18	QPixmap::QPixmap	qpixmap.cpp	260	0x65198eda	
19	createData	concurrenttest.cpp	15	0x40165f	
20 
QtConcurrent::StoredFunctorCall2<QPair<QPixmap,QString>,QPair<QPixmap,QString> 
(__cdecl*)(QString,QSize),QString,QSize>::runFunctor 
qtconcurrentstoredfunctioncall.h	484	0x4030f5	
21	QtConcurrent::RunFunctionTask<QPair<QPixmap,QString> >::run 
qtconcurrentrunbase.h	104	0x40319a	
22	QThreadPoolThread::run	qthreadpool.cpp	106	0x6704fda8	
23	QThreadPrivate::start	qthread_win.cpp	317	0x67064a3f	
24	beginthreadex	MSVCR90D	0	0x6bd6dfd3	
25	beginthreadex	MSVCR90D	0	0x6bd6df69	
26	BaseThreadInitThunk	kernel32	0	0x76233677	
27	RtlInitializeExceptionChain	ntdll	0	0x77669d42	
28	RtlInitializeExceptionChain	ntdll	0	0x77669d15	

and the message

HEAP[Concurrent.exe]: Invalid address specified to RtlValidateHeap( 
003F0000, 0B5DA5E8 )



More information about the Qt-interest-old mailing list