I am working on a project recently migrated to Qt 5.3.0 (previously it was running on Qt 5.2.1).
My project is based on a QQuickView object being filled with some QML files, depending on some command I receive from a communication protocol...
Since I was on Qt 5.2.1 the system worked fine and was rock solid: never a problem. Now with Qt 5.3.0 if I close the QQuickView window the process crashes with the following output:
** glibc detected ** /home/morix/devel/aesys/VLED/build/bin/VLED: free(): invalid pointer: 0x091ec694 **
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb5c1fee2] /usr/lib/i386-linux-gnu/libstdc++.so.6(_ZdlPv+0x1f)[0xb5e1b51f] /opt/Qt/5.3/gcc/lib/libQt5Qml.so.5(_ZN21QQmlImageProviderBaseD0Ev+0x24)[0xb7136110] /opt/Qt/5.3/gcc/lib/libQt5Qml.so.5(+0x211f59)[0xb713cf59] /opt/Qt/5.3/gcc/lib/libQt5Qml.so.5(+0x2138b3)[0xb713e8b3] /opt/Qt/5.3/gcc/lib/libQt5Core.so.5(_ZN9QHashData11free_helperEPFvPNS_4NodeEE+0x4a)[0xb5f40e7a] /opt/Qt/5.3/gcc/lib/libQt5Qml.so.5(_ZN17QQmlEnginePrivateD1Ev+0x8ab)[0xb71378c5] /opt/Qt/5.3/gcc/lib/libQt5Qml.so.5(_ZN17QQmlEnginePrivateD0Ev+0x1c)[0xb7137a7c] /opt/Qt/5.3/gcc/lib/libQt5Core.so.5(_ZN7QObjectD1Ev+0x6a1)[0xb6173031] /opt/Qt/5.3/gcc/lib/libQt5Qml.so.5(_ZN9QJSEngineD1Ev+0x36)[0xb70352b6] /opt/Qt/5.3/gcc/lib/libQt5Qml.so.5(_ZN10QQmlEngineD1Ev+0xf0)[0xb71398fe] /opt/Qt/5.3/gcc/lib/libQt5Qml.so.5(_ZN10QQmlEngineD0Ev+0x1c)[0xb71399e2] /opt/Qt/5.3/gcc/lib/libQt5Core.so.5(_ZN14QObjectPrivate14deleteChildrenEv+0x6c)[0xb616e4ac] /opt/Qt/5.3/gcc/lib/libQt5Core.so.5(_ZN7QObjectD1Ev+0x661)[0xb6172ff1] /opt/Qt/5.3/gcc/lib/libQt5Gui.so.5(_ZN7QWindowD2Ev+0x6d)[0xb646a7bd] /opt/Qt/5.3/gcc/lib/libQt5Quick.so.5(_ZN12QQuickWindowD1Ev+0xd9)[0xb74878e9] /opt/Qt/5.3/gcc/lib/libQt5Quick.so.5(_ZN10QQuickViewD1Ev+0x9a)[0xb753925a] /home/morix/devel/aesys/VLED/build/bin/VLED[0x8059bbe] /home/morix/devel/aesys/VLED/build/bin/VLED[0x8059c8f] /home/morix/devel/aesys/VLED/build/bin/VLED[0x8051368] /home/morix/devel/aesys/VLED/build/bin/VLED[0x804d429] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb5bc34d3] /home/morix/devel/aesys/VLED/build/bin/VLED[0x804d2b1]
(VLED is the name of my project in the output here above).
It seems that some free() call in QQmlImageProviderBase is working on a unvalid pointer...
Please consider that in my project I make use of a QQmlImageProviderBase-derived class to provide some "live" pixmaps to QML... but I don't think the problem is there: the code is very simple (simply returns some pixmaps previously inserted in a local collection) and furthermore with Qt 5.2.1 it works fine...
I am working on Ubuntu Linux 12.04 LTS... but the problem is the same if I cross-compile the application for BeagleBone Black / TI AM335x... so it seems not to be an "environment-related" problem but rather a Qt problem...
Does somebody else is experiencing such a problem with Qt 5.3.0? Any workaround?
UPDATE
I created a very simply project for reproducing the issue: it can be found here here.
Please try it on your own and let me know if you have the same issue and if you find a valid workaround…
Ok, I posted the question on Qt bug tracker and here is the answer: the QQmlImageProviderBase
-derived object must be allocated on the heap because the QQmlEngine
takes the ownership of it when it is added to the view... If it is allocated on the stack the object is going to be deleted twice (once by QQmlEngine and once when the stack is popped)...
Allocating it on the heap (as suggested) and letting QQmlEngine
to delete it on its own fixes the problem.