QVariantList crashed when call destructor



  • I'm new to Qt
    I have a strange crash when a QVariantList is destroyed.
    I write a small code to reproduice it.
    I use another methode to decode the json array, but I want to understand why.
    Qt 5.5.1
    Visual Sudio 2017
    Windows 10 64bit

    const char cFile[] = { "{\"Ids\":[0,1,2]}" };
    
    void TestJson(void)
    {
    	QByteArray Doc = QByteArray::fromRawData(cFile, strlen(cFile));
    	QJsonDocument jDoc = QJsonDocument::fromJson(Doc);
    	QJsonValue jVal = jDoc.object().value("Ids");
    	if (!jVal.isArray())
    		return;
    	QJsonArray jArr = jVal.toArray();
    	QVariantList list = jArr.toVariantList();
    	return;	// crash !!!!!!!!!
    }	
    
    int main(int argc, char *argv[])
    {
    	TestJson();
    }
    

    Call stack

    ucrtbased.dll!free_dbg_nolock(void * const block=0x00a840d8, const int block_use=16) Ligne 908	C++
    ucrtbased.dll!_free_dbg(void * block=0x00a840d8, int block_use=-1) Ligne 1030	C++
    AcqV7.exe!operator delete(void * block=0x00a840d8) Ligne 17	C++
    AcqV7.exe!operator delete(void * block=0x00a840d8, unsigned int __formal=16) Ligne 15	C++
    AcqV7.exe!QVariant::`scalar deleting destructor'(unsigned int)	C++
    >	AcqV7.exe!QList<QVariant>::node_destruct(QList<QVariant>::Node * from=0x00a87798, QList<QVariant>::Node * to=0x00a877a0) Ligne 463	C++
    AcqV7.exe!QList<QVariant>::dealloc(QListData::Data * data=0x00a87788) Ligne 836	C++
    AcqV7.exe!QList<QVariant>::~QList<QVariant>() Ligne 797	C++
    AcqV7.exe!TestJson() Ligne 67	C++
    AcqV7.exe!main(int argc=1, char * * argv=0x00a880e8) Ligne 76	C++
    

  • Qt Champions 2016

    Could you try with:

    QByteArray Doc(cFile);
    


  • @OcaJLSA

    your example does not crash for me, 5.9.1 with MSCV2015(32b).

    Exact Copy main.cpp:

    #include <QByteArray>
    #include <QJsonArray>
    #include <QJsonDocument>
    #include <QJsonObject>
    #include <QVariant>
    
    const char cFile[] = { "{\"Ids\":[0,1,2]}" };
    
    void TestJson(void)
    {
        QByteArray Doc = QByteArray::fromRawData(cFile, strlen(cFile));
        QJsonDocument jDoc = QJsonDocument::fromJson(Doc);
        QJsonValue jVal = jDoc.object().value("Ids");
        if (!jVal.isArray())
            return;
        QJsonArray jArr = jVal.toArray();
        QVariantList list = jArr.toVariantList();
        return;	// crash !!!!!!!!!
    }
    
    int main(int argc, char *argv[])
    {
        TestJson();
    }
    

    TestJson.pro

    QT += core
    QT -= gui
    
    CONFIG += c++11
    
    TARGET = TestJson
    CONFIG += console
    CONFIG -= app_bundle
    
    TEMPLATE = app
    
    SOURCES += main.cpp
    
    DEFINES += QT_DEPRECATED_WARNINGS
    

  • Qt Champions 2016

    In light of what @J-Hilk reports, you should search for a bug in the tracker to confirm this for Qt 5.5 and upgrade your Qt version.



  • It's impossible to update the Qt version, because my program will run on a wince7 device.
    QT 5.9.1 is not compatible.
    I will try to build on an other computer with QT 5.8
    Thanks



  • Tested with Qt 5.8 and 5.5. both working



  • @OcaJLSA
    5.7 5.5 work


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.