A crash with this message:
The inferior stopped because it received a signal from the operating system.
Signal name : SIGABRT
Signal meaning : Aborted
happens at this line of code:
// data is QByteArray ...
QByteArray pos0 = data.mid( index, length );
/*
* Get float from byte-array
*/
QDataStream streamPos0(pos0);
QVector<float> floatPos0;
streamPos0 >> floatPos0; // Crash happens exactly at this line
I couldn't figure out why the crash happens. I wonder if anybody can give me a hint ...
UPDATE
I stepped through the code and captured the local values when the code is exactly at the crash line:
data "fý¾¾PY\001À\216\224\033ÁµÏ4½\020\233µ½±½~¿f?ÿ¾@Q\001Àî}\033ÁµÏ4½\020\233µ½±½~¿f?ÿ¾ì\007`¿\010 \035ÁµÏ4½\020\233µ½±½~¿z\n~¾\017?`¿´F\035ÁØÙ\000½Ó±µ½\003Ý~¿z\n~¾"... (846288) QByteArray
index 0 int
length 12 quint64
pos0 "fý¾¾PY\001À\216\224\033Á" QByteArray
streamPos0 @0x7fffffff7bb0 QDataStream
byteorder QDataStream::BigEndian (0x0000) QDataStream::ByteOrder
d (null) QScopedPointer<QDataStreamPrivate>
dev @0x12f0d60 QIODevice
noswap false bool
owndev true bool
q_status QDataStream::Ok (0x0000) QDataStream::Status
ver 17 int
floatPos0 <0 items>
The exact location of crash is at this line in the file qdatastream.h
:
template <typename Container>
QDataStream &readArrayBasedContainer(QDataStream &s, Container &c)
{
StreamStateSaver stateSaver(&s);
c.clear();
quint32 n;
s >> n;
c.reserve(n); // crash happens exactly here
for (quint32 i = 0; i < n; ++i) {
typename Container::value_type t;
s >> t;
if (s.status() != QDataStream::Ok) {
c.clear();
break;
}
c.append(t);
}
return s;
}
I tried assigning a size to my QVector<float> floatPos0
by .reserve()
and .resize()
methods but it didn't help.
I'm using Qt 5.9.4