Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Crash when using a ValueAxis in a ChartView. Why?



  • I'm using Qt quick controls 2 5.10...

    I have a chartView inside of a popup. The display of the data works as expected, but the app is crashing on quit.

    Here's a simplified version of the popup and chart:

    Popup {
        id:myPopup
    
        modal: true
        focus: false
        dim: true
        topPadding: 0
        rightPadding:0
        leftPadding: 0
        bottomPadding: 0
    
        }
    
        ChartView {
            id: chartView
    
            ValueAxis {
                id: valueAxisX
            }
    
            LineSeries {
                axisX: valueAxisX
                //axisY: valueAxisY
                name: "Power"
                XYPoint { x: 0; y: 0 }
                XYPoint { x: 1.1; y: 2.1 }
                XYPoint { x: 1.9; y: 3.3 }
                XYPoint { x: 2.1; y: 2.1 }
                XYPoint { x: 2.9; y: 4.9 }
                XYPoint { x: 3.4; y: 3.0 }
                XYPoint { x: 4.1; y: 3.3 }
            }
    
        }   //chartView
    
    }
    

    The crash log looks like this:

    Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
    0   org.qt-project.QtQml          	0x0000000111f4215b QQmlContextData::ContextGuard::objectDestroyed(QObject*) + 43
    1   org.qt-project.QtQml          	0x0000000111f25209 QQmlData::destroyed(QObject*) + 441
    2   org.qt-project.QtCore         	0x0000000112464bbf QObject::~QObject() + 319
    3   libqtchartsqml2.dylib         	0x00000001238d0710 QQmlPrivate::QQmlElement<QtCharts::QValueAxis>::~QQmlElement() + 32
    4   org.qt-project.QtQml          	0x0000000111d71cc8 QV4::MemoryManager::sweep(bool, void (*)(char const*)) + 296
    5   org.qt-project.QtQml          	0x0000000111d72c69 QV4::MemoryManager::~MemoryManager() + 57
    6   org.qt-project.QtQml          	0x0000000111e495f7 QV4::ExecutionEngine::~ExecutionEngine() + 87
    7   org.qt-project.QtQml          	0x0000000111fca560 QV8Engine::~QV8Engine() + 176
    8   org.qt-project.QtQml          	0x0000000111fca66e QV8Engine::~QV8Engine() + 14
    9   org.qt-project.QtQml          	0x0000000111df53ff QJSEngine::~QJSEngine() + 79
    10  org.qt-project.QtQml          	0x0000000111f26582 QQmlEngine::~QQmlEngine() + 370
    11  com.onsemi.usb-pd             	0x000000010bbe0bac main + 2828 (main.cpp:118)
    12  libdyld.dylib                 	0x00007fff6383b015 start + 1
    

    There's no crash unless the LineSeries references a ValueAxis. Once it accesses a ValueAcess, no matter how simple, the app will crash in QQmlPrivate::QQmlElementQtCharts::QValueAxis::~QQmlElement() as shown above.

    Does anyone have any idea what the issue is, or how I can go about debugging the problem?



  • I don't see where you've instanced valueAxisY ?

    Are you assigning an null / undefined object to the series y axis?



  • @6thC I initially had an instance of valueAxisY, but in the process of simplifying things, I realized that all I needed to do to make the app crash was to have a reference to a single ValueAxis.

    If that bothers you, just copy the valueAxisX, and rename the copy ValueAxisY, and uncomment the axisY line for the LineSeries.


  • Moderators

    @igor_stravinsky Is there any c++ code behind this project or is it just pure QML? If it's qml can you share some code that we could run in qmlscene to duplicate the isssue? If it has a C++ backing to it, can you share that code (assuming it's relatively simple)?



  • @igor_stravinsky

    If that bothers you, just copy the valueAxisX, and rename the copy ValueAxisY, and uncomment the axisY line for the LineSeries.

    Personally? I couldn't actually care any less.

    We're just all working with what you give us so it's actually if you care to give us enough information to actually help you. Providing actual code or at least as close as possible is always going to help.

    With half cut, incomplete fragments ... we'll just all guess, you'll have as much luck tossing darts blindfolded.

    This is from the LineSeries and ChartView documentation pages and best I can tell what you want. It's pure QML. Using Windows/Qt5.10.0/MinGW5.3.0 I can verify this runs for me, so actual code.

    //QML:
    
            Button {
            text: "Open"
            onClicked: popup.open()
        }
    
            Popup {
                id: popup
                x: 100
                y: 100
                width: 200
                height: 300
                modal: true
                focus: true
                closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
    ChartView {
        title: "Line"
        anchors.fill: parent
        antialiasing: true
        ValueAxis {
            id: xAxis
            min: 0
            max: 10
        }
        ValueAxis {
            id: yAxis
            min: 0
            max: 10
        }
        LineSeries {
            name: "LineSeries"
            axisX: xAxis
            axisY: yAxis
            XYPoint { x: 0; y: 0 }
            XYPoint { x: 1.1; y: 2.1 }
            XYPoint { x: 1.9; y: 3.3 }
            XYPoint { x: 2.1; y: 2.1 }
            XYPoint { x: 2.9; y: 4.9 }
            XYPoint { x: 3.4; y: 3.0 }
            XYPoint { x: 4.1; y: 3.3 }
        }
    }
            }
    }
    


  • @ambershark There's no C++ backing. The code is pure QML, although the graph is showing data from an outside source. I removed that source to see if that were part of the problem, and discovered that even graphic a fixed number of points would generate a crash on quit.

    Interestingly, I added a StackedBarSeries to another section of my app yesterday, and now that is generating a similar crash on quit.

    Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
    0   org.qt-project.QtQml          	0x0000000115f7815b QQmlContextData::ContextGuard::objectDestroyed(QObject*) + 43
    1   org.qt-project.QtQml          	0x0000000115f5b209 QQmlData::destroyed(QObject*) + 441
    2   org.qt-project.QtCore         	0x000000011649bbbf QObject::~QObject() + 319
    3   libqtchartsqml2.dylib         	0x0000000127caa468 QQmlPrivate::QQmlElement<QtCharts::DeclarativeStackedBarSeries>::~QQmlElement() + 56
    4   org.qt-project.QtQml          	0x0000000115da7cc8 QV4::MemoryManager::sweep(bool, void (*)(char const*)) + 296
    5   org.qt-project.QtQml          	0x0000000115da8c69 QV4::MemoryManager::~MemoryManager() + 57
    6   org.qt-project.QtQml          	0x0000000115e7f5f7 QV4::ExecutionEngine::~ExecutionEngine() + 87
    7   org.qt-project.QtQml          	0x0000000116000560 QV8Engine::~QV8Engine() + 176
    8   org.qt-project.QtQml          	0x000000011600066e QV8Engine::~QV8Engine() + 14
    9   org.qt-project.QtQml          	0x0000000115e2b3ff QJSEngine::~QJSEngine() + 79
    10  org.qt-project.QtQml          	0x0000000115f5c582 QQmlEngine::~QQmlEngine() + 370
    11  com.onsemi.usb-pd             	0x000000010fc158ac main + 2828 (main.cpp:118)
    12  libdyld.dylib                 	0x00007fff6383b015 start + 1
    

    Could the problem be an issue at a higher level involving QtCharts in general? I'm using QtQuick 2.10 and QtCharts 2.2


  • Moderators

    @igor_stravinsky This is starting to sound like it's a mixing Qt versions problem. It sounds like it's using a mix of versions 5.8/5.10/etc. I would find out which version of Qt it is loading when run versus what you expect it to be running. If the version is correct make sure all the (so/dlls) are for the same version of Qt. On linux you can use ldd on windows dependency walker.

    It's also possible you have a corrupt Qt library, albeit unlikely. If you have another system to test on that would help too. It works for me, and seems to work for @6thC so it's more than likely something with your Qt install.

    Again if you can share a simple full .qml file that can reproduce the issue I can test locally for your exact code. Always nice to share a snippet that can reproduce the problem. It could be a bug in Qt, but it's not sounding like it. My money is on bad Qt mixes on your system.



  • @igor_stravinsky said in Crash when using a ValueAxis in a ChartView. Why?:

    com.apple.main-thread

    Perhaps the environment / charts too?

    Is this iOS? I'm using charts under MinGW || GCC
    Qt 5.10 and 5.10.1
    under linux, linux VM, win10
    Perhaps this is something for the mailing list or yes, a corrupt library?

    Did that basic example / exact qml code I sent you work?
    Cause that had button, a popup containing the chartview w/x&y axis + attached lineseries ready to go.



  • @ambershark Mixed versions is a thought I had as well. I just did an update to 5.11, and am testing that out. I'll try to get a simple example that crashes for me posted shortly.

    @6thC I just installed 5.11, and updated headers, so hopefully the project is now current. I'm compiling on MacOS, and the example you posted worked without a problem for me.

    The first crash comes when a ChartView is in a Popup, and the second happens when a ChartView is in a ToolTip, and the crash only happens when the app is quitting, so I'm wondering if the fact that the chart isn't part of a standard qml page (i.e. it's only shown sometimes) has to do with the crash on in the destructor. When I show a chart on a page not on a Popup or ToolTip, it works without a problem.



  • Are you on a commercial license. That sounds the sort of thing I'd touch base for confirming / getting a bug raised. I think you can directly, I just have a commercial so use the support first, they confirm or deny and even raise bugs for me. It's very much appreciated for a small project (sole developer) as myself.

    I'm sorry I have no mac / ios equipment / dev env here to reproduce for you. I think this has narrowed the situation down (potentially) to limited to this system or your specific environment. Hopefully another qt dev using IOS can help? If you have a standalone project with working and broken examples I'd suggest that always helps.

    We're lazy (try to be efficient) and time limited so if you already have something others can just hit F5 and confirm or deny expectations and behavior - it'd only be appreciated.



  • @6thC Sadly, I'm working under a free, not commercial license. No support for me...

    I have replicated one of my bugs. I'll post that code.



  • Here's a simple example of a chart causing a crash on quit. In this case the chart is inside of a ToolTip

    main.qml:

    import QtQuick 2.11
    import QtQuick.Window 2.11
    import QtQuick.Controls 1.4
    
    Window {
        visible: true
        width: 1200
        height: 800
        title: qsTr("Hello World")
    
        Button{
            id:testButton
            text:"test"
            anchors.centerIn:parent
            height:parent.height/8
            width:parent.width/8
    
            CustomToolTip{
                visible: testButton.hovered
            }
        }
    }
    

    CustomToolTip:

    import QtQuick 2.11
    import QtQuick.Layouts 1.3
    import QtQuick.Controls 2.4
    import QtCharts 2.2
    
    ToolTip{
        delay: 0
    
        Rectangle{
            id:tooltipBackgound
            width:400
            height:300
            radius:10
            border.color:"black"
    
            ChartView {
                title: "Memory"
                antialiasing: true
    
                PieSeries {
                        id: pieSeries
                        PieSlice { label: "eaten"; value: 94.9 }
                        PieSlice { label: "not yet eaten"; value: 5.1 }
                    }
            }
        }   //background rectangle
    }
    

    I don't think the crash actually requires a series of any sort. Simply having a chart view in the tool tip seem to be sufficient.

    Crash stack trace:

    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0   org.qt-project.QtQml          	0x0000000106033ccb QQmlContextData::ContextGuard::objectDestroyed(QObject*) + 43
    1   org.qt-project.QtQml          	0x00000001060161c9 QQmlData::destroyed(QObject*) + 489
    2   org.qt-project.QtCore         	0x000000010656924f QObject::~QObject() + 319
    3   libqtchartsqml2.dylib         	0x000000010d010b48 QQmlPrivate::QQmlElement<QtCharts::DeclarativePieSeries>::~QQmlElement() + 56
    4   org.qt-project.QtQml          	0x0000000105ea8bf8 QV4::MemoryManager::sweep(bool, void (*)(char const*)) + 296
    5   org.qt-project.QtQml          	0x0000000105ea9b62 QV4::MemoryManager::~MemoryManager() + 66
    6   org.qt-project.QtQml          	0x0000000105f2eb57 QV4::ExecutionEngine::~ExecutionEngine() + 87
    7   org.qt-project.QtQml          	0x0000000105f25057 QJSEngine::~QJSEngine() + 103
    8   org.qt-project.QtQml          	0x0000000106017572 QQmlEngine::~QQmlEngine() + 370
    9   com.onsemi.ToolTipCrashTest   	0x0000000105ab5033 main + 339 (main.cpp:17)
    10  libdyld.dylib                 	0x00007fff6383b015 start + 1
    
    


  • Here's a simple example of a chart in a popup which causes a crash on quit on my system (MacOS, running Qt 5.11)

    main.qml

    import QtQuick 2.11
    import QtQuick.Window 2.11
    import QtQuick.Controls 1.4
    
    Window {
        id:mainWindow
        visible: true
        width: 1200
        height: 800
        title: qsTr("Hello World")
    
        Button{
            id:testButton
            text:"test"
            anchors.centerIn:parent
            height:parent.height/8
            width:parent.width/8
    
            onClicked: { customGraph.open() }
        }
    
        CustomPopup{
            id:customGraph
            width: mainWindow.width/2
            height: mainWindow.height/2
            leftMargin: mainWindow.width/4
            topMargin: mainWindow.height/4
        }
    }
    
    

    CustomPopup.qml:

    import QtQuick 2.11
    import QtQuick.Controls 2.4
    import QtCharts 2.2
    
    Popup {
        id: customPopup
    
        modal: true
        focus: false
        dim: true
    
        ChartView {
            id: chartView
            title: "Custom Chart"
            height: parent.height
            antialiasing: true
            theme: ChartView.ChartThemeDark
    
            ValueAxis {
                id: valueAxisX
            }
    
            ValueAxis{
                id: valueAxisY
            }
    
            LineSeries {
                id: powerSeries
                axisX: valueAxisX
                axisY: valueAxisY
                name: "Series"
            }
    
        }   //chartView
    
    }
    

    And the stack trace from the crash:

    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0   org.qt-project.QtQml          	0x0000000104be9ccb QQmlContextData::ContextGuard::objectDestroyed(QObject*) + 43
    1   org.qt-project.QtQml          	0x0000000104bcc1c9 QQmlData::destroyed(QObject*) + 489
    2   org.qt-project.QtCore         	0x000000010512324f QObject::~QObject() + 319
    3   libqtchartsqml2.dylib         	0x000000010bae06f0 QQmlPrivate::QQmlElement<QtCharts::QValueAxis>::~QQmlElement() + 32
    4   org.qt-project.QtQml          	0x0000000104a5ebf8 QV4::MemoryManager::sweep(bool, void (*)(char const*)) + 296
    5   org.qt-project.QtQml          	0x0000000104a5fb62 QV4::MemoryManager::~MemoryManager() + 66
    6   org.qt-project.QtQml          	0x0000000104ae4b57 QV4::ExecutionEngine::~ExecutionEngine() + 87
    7   org.qt-project.QtQml          	0x0000000104adb057 QJSEngine::~QJSEngine() + 103
    8   org.qt-project.QtQml          	0x0000000104bcd572 QQmlEngine::~QQmlEngine() + 370
    9   com.onsemi.ToolTipCrashTest   	0x000000010466aca3 main + 339 (main.cpp:17)
    10  libdyld.dylib                 	0x00007fff6383b015 start + 1
    

    Any idea why this is happening?


  • Moderators

    @igor_stravinsky I will try to get some time to update to 5.11 on my mac and test for you to see if it happens on my system too.

    In this case though it really is looking more and more like a bug in Qt. I would try reporting it with that code that makes it reproducible.

    If you link the bug report here I will try to upvote it if I can reproduce it when I get time/updates to my mac.

    Sadly, I'm working under a free, not commercial license.

    Since you are using Qt Charts, just be careful with licensing. Qt Charts is only available under commerical and GPL licenses. You can't make a closed source (LGPL) product with Qt Charts unless you have a commercial license. Just wanted to warn you in case you weren't aware so you didn't end up in trouble later. :)



  • @ambershark Thanks for the reminder about QtCharts being under GPL. I've noted that, and alerted the powers that be above me. I'm not sure if they realize the ramifications right now, but they will...

    And I don't think this issue requires an update to 5.11. I was having the problem under 5.10, but upgraded to test if this was still an issue under the new version.



  • I'd encourage your "higher ups" that commercial is affordable and very worth it.


  • Moderators

    @igor_stravinsky said in Crash when using a ValueAxis in a ChartView. Why?:

    And I don't think this issue requires an update to 5.11

    My mac is on like 5.2 though, so I'd definitely update it before messing around. I haven't written any commercial software for the mac in a while so I haven't updated it recently. I've been busy the last week and haven't had time to even answer questions on the forums much less delve into problems like this. So I never got around to testing it.

    Did you ever file a bug?



  • @ambershark QTBUG-68483 has been filed.



  • I get the same thing: Qt 5.12.0, my ChartView with ValueAxis is in a Page in a StackView, crashes on exit.
    Noticeable is that if I unwind the StackView before exiting, the application doesn't crash.


Log in to reply