QMap::clear() crash

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



QMap::clear() crash



I'm running Qt-4.8.6 on Linux i686



I have a


QMap<quint32, QTreeWidgetItem *> mymap;



and when I simply call


mymap.clear();



the program crashes with stacktrace


...
#7 <signal handler called>
#8 0x0806f50c in QBasicAtomicInt::deref (this=0x34) at /usr/local/Trolltech/Qt-4.8.6/include/QtCore/qatomic_i386.h:110
#9 0xa968c452 in QMap<unsigned int, QTreeWidgetItem*>::operator= (this=0xc53c51c, other=@0xbfa04b28)
at /usr/local/Trolltech/Qt-4.8.6/include/QtCore/qmap.h:412
#10 0xa968c4d1 in QMap<unsigned int, QTreeWidgetItem*>::clear (this=0xc53c51c)
at /usr/local/Trolltech/Qt-4.8.6/include/QtCore/qmap.h:424
...



Sorry I can't paste full stacktrace/code cuz I don't own the code.



This problem doesn't happen every time, or I should say it happens very rarely, but it did happen. I googled but only found things like "reinstall Qt", "use same compiler", etc.



Is there anything else I can do?



EDIT



I can paste some related Qt source code if that helps


// qmap.h
template <class Key, class T>
Q_INLINE_TEMPLATE void QMap<Key, T>::clear()

*this = QMap<Key, T>();


template <class Key, class T>
Q_INLINE_TEMPLATE QMap<Key, T> &QMap<Key, T>::operator=(const QMap<Key, T> &other)

if (d != other.d)
QMapData* o = other.d;
o->ref.ref();
if (!d->ref.deref())
freeData(d);
d = o;
if (!d->sharable)
detach_helper();

return *this;


// qatomic_i386.h
inline bool QBasicAtomicInt::deref()

unsigned char ret;
asm volatile("lockn"
"decl %0n"
"setne %1"
: "=m" (_q_value), "=qm" (ret)
: "m" (_q_value)
: "memory");
return ret != 0;





Without an MCVE there is not much we can do to help. Use a debugger and check where the code crashes exactly.
– Sebastian
Aug 10 at 8:58





If it doesn't happen every time, you have something undefined in your code. The this=0x34 suggests that there is a null pointer somewhere. That there is any kind of problem with clear suggests that the map itself has become corrupted somehow.
– molbdnilo
Aug 10 at 9:02


this=0x34


clear





The two lines posted do not crash so in actual code the map itself is either already destroyed or corrupted by something.
– Öö Tiib
Aug 10 at 9:08





@molbdnilo You're right, thanks for correcting me.
– lubgr
Aug 10 at 9:10









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard