Crash using a big string in QML Qt 5.5.0 (no crash in 5.4)



  • I have some QML code which is running alright in Qt 5.4 but crashes in my later 5.5.0.

    The original code in 5.4 was a log-to-file mechanism. Instead of writing to a file at each logging call, I would append to a string, then a timer would occasionally get the string, write the string to a file (via C++/QML integration) and clear the string.

    After switching to 5.5 I noticed a crash. I eventually reduced the code to be just QML, no C++ call at all.

    property string logBuffer = ""
    
    // Place this in some rectangle you can click
    MouseArea {
    anchors.fill: parent
    onClicked: {
        console.log("Started constructing long string.");
        var str = "Something worthy of logging. For the sake of the test, I make the string a bit longer than usual, to see if there is an effect..."
        // You can increase / decrease the number of iterations
        for (var i = 0; i < 3000; i++) {
            logBuffer = logBuffer + str + i + "\n";
        }
        console.log("Long string constructed.")
    
        console.log("Clear buffer of length " + logBuffer.length);
        if (logBuffer.length > 0) {
            logBuffer = "";
        }
    }
    

    After several calls I get a crash "R6010 abort() has been called".

    I'm not even sure if this a QTBUG or I'm really misusing the QML here, mainly not sure why the newer version behaves differently.



  • It works ok for me with 5.4.2 and 5.5.1 on Linux. The behavior is better with 5.5.1; 5.4.2 uses over 1GB of RAM after a few clicks.


Log in to reply
 

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