[Qt-interest] Bug with QVector on really large data sets

David Boosalis david.boosalis at gmail.com
Fri Feb 12 20:59:49 CET 2010


I am using qt-everywhere-opensource-src-4.6.1/ on a 64 bit OS.  I get a core
dump from QVector <QByteArray> object I have.

After about 826 appends of a QByteArray object of size about 52 it core
dumps with the  trace given below.  For large Vectors should I try to
reserve space to handle large vectors. Doing this presents a problem in that
I never know how many records will coming in. It could be 1 or in this case
it might be close to a 1000.  To reserve space for the worst case scenario
would really waste a lot of resources for me.

Any adivse on how to get around or fix this issue ?
Thank you
David

----------------  Trace back -------------------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff3c65910 (LWP 9370)]
0x00007ffff5389ef0 in ?? () from /lib/libc.so.6
(gdb) where
#0  0x00007ffff5389ef0 in ?? () from /lib/libc.so.6
#1  0x00007ffff538c509 in ?? () from /lib/libc.so.6
#2  0x00007ffff538e82e in malloc () from /lib/libc.so.6
#3  0x000000000043adf3 in QVector<QByteArray>::malloc (this=0x6dbbe8,
aalloc=1022)
    at
../../../qt/qt-everywhere-opensource-src-4.6.1/mkspecs/linux-g++-64/../../../qt-everywhere-opensource-src-4.6.1/src/corelib/tools/qvector.h:391
#4  0x000000000043a80e in QVector<QByteArray>::realloc (this=0x6dbbe8,
asize=826, aalloc=1022)
    at
../../../qt/qt-everywhere-opensource-src-4.6.1/mkspecs/linux-g++-64/../../../qt-everywhere-opensource-src-4.6.1/src/corelib/tools/qvector.h:468
#5  0x000000000043a181 in QVector<QByteArray>::append (this=0x6dbbe8, t=...)
    at
../../../qt/qt-everywhere-opensource-src-4.6.1/mkspecs/linux-g++-64/../../../qt-everywhere-opensource-src-4.6.1/src/corelib/tools/qvector.h:547
#6  0

-------------------Top Offending line of code in qvector.h:
inline QVectorData *QVector<T>::malloc(int aalloc)
{
    QVectorData *vectordata = QVectorData::allocate(sizeOfTypedData() +
(aalloc - 1) * sizeof(T), alignOfTypedData());  //qvector.h 391
    Q_CHECK_PTR(vectordata);
    return vectordata;
}
.....

            x.d = malloc(aalloc);  // qvector.h 468
            Q_CHECK_PTR(x.p);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100212/ad676ee3/attachment.html 


More information about the Qt-interest-old mailing list