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

Application randomly crashes on segmentation fault.



  • Hello guys,

    when running a qt5 app it sometimes crashes on segmentation fault. This happens on random places in application and I have not been able to pinpoint why. I went forward to debugging it with gdc and got this output:

    Program received signal SIGSEGV, Segmentation fault.
    0xb5dd2580 in QV4::QObjectWrapper::wrap(QV4::ExecutionEngine*, QObject*) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    (gdb) bt
    #0 0xb5dd2580 in QV4::QObjectWrapper::wrap(QV4::ExecutionEngine*, QObject*) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #1 0xb5dcd2f4 in QV4::ExecutionEngine::fromVariant(QVariant const&) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #2 0xb5e184c5 in QV4::QmlContextWrapper::get(QV4::Managed const*, QV4::String*, bool*) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #3 0xb5dd63a1 in QV4::ExecutionContext::getProperty(QV4::String*) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #4 0xb5e6a962 in QV4::Runtime::method_getActivationProperty(QV4::ExecutionEngine*, int) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #5 0xac7e1d9d in ?? ()
    #6 0xb5dd76e9 in QV4::ExecutionContext::simpleCall(QV4::Scope&, QV4::CallData*, QV4::Function*) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #7 0xb5f0d8ce in QQmlJavaScriptExpression::evaluate(QV4::CallData*, bool*, QV4::Scope&) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #8 0xb5e9f73f in QQmlBoundSignalExpression::evaluate(void**) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #9 0xb5ea08d1 in ?? () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #10 0xb5ee92a2 in QQmlNotifier::emitNotify(QQmlNotifierEndpoint*, void**) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #11 0xb5e81638 in QQmlData::signalEmitted(QAbstractDeclarativeData*, QObject*, int, void**) () from /usr/share/qt5.9.6/lib/libQt5Qml.so.5
    #12 0xb57ada54 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #13 0xb57ae4db in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #14 0xaa095ac5 in QQuickWebView::urlChanged() () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #15 0xaa098f54 in QQuickWebView::emitUrlChangeIfNeeded() () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #16 0xaa09c4f1 in QQuickWebViewPrivate::didStartProvisionalLoadForFrame(OpaqueWKPage const*, OpaqueWKFrame const*, void const*, void const*) () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #17 0xa9fcb06e in WebKit::WebLoaderClient::didStartProvisionalLoadForFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::APIObject*) () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #18 0xa9fee1d3 in WebKit::WebPageProxy::didStartProvisionalLoadForFrame(unsigned long long, WTF::String const&, WTF::String const&, CoreIPC::MessageDecoder&) () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #19 0xaa0d0754 in void CoreIPC::handleMessageVariadic<Messages::WebPageProxy::DidStartProvisionalLoadForFrame, WebKit::WebPageProxy, void (WebKit::WebPageProxy::)(unsigned long long, WTF::String const&, WTF::String const&, CoreIPC::MessageDecoder&)>(CoreIPC::MessageDecoder&, WebKit::WebPageProxy, void (WebKit::WebPageProxy::)(unsigned long long, WTF::String const&, WTF::String const&, CoreIPC::MessageDecoder&)) ()
    from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #20 0xaa0dae8b in WebKit::WebPageProxy::didReceiveMessage(CoreIPC::Connection
    , CoreIPC::MessageDecoder&) () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #21 0xa9f2416b in CoreIPC::MessageReceiverMap::dispatchMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #22 0xa9f3f35e in WebKit::ChildProcessProxy::dispatchMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #23 0xa9ff582e in WebKit::WebProcessProxy::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #24 0xa9f1e73c in CoreIPC::Connection::dispatchMessage(WTF::PassOwnPtrCoreIPC::MessageDecoder) () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #25 0xa9f1e89d in CoreIPC::Connection::dispatchOneMessage() () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #26 0xa9f1d692 in WTF::BoundFunctionImpl<WTF::FunctionWrapper<void (CoreIPC::Connection::)()>, void (CoreIPC::Connection)>::operator()() () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #27 0xaa3a238c in WebCore::RunLoop::performWork() () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #28 0xaa476a37 in WebCore::RunLoop::TimerObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/share/qt5.9.6/qml/QtWebKit/../../lib/libQt5WebKit.so.5
    #29 0xb57aadeb in QMetaCallEvent::placeMetaCall(QObject*) () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #30 0xb57af2bd in QObject::event(QEvent*) () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #31 0xb66bf22c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/share/qt5.9.6/lib/libQt5Widgets.so.5
    #32 0xb66c6d24 in QApplication::notify(QObject*, QEvent*) () from /usr/share/qt5.9.6/lib/libQt5Widgets.so.5
    #33 0xb577f3f3 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #34 0xb5781c3c in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #35 0xb57d5a55 in QEventDispatcherUNIX::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #36 0xb346e2a5 in ?? () from /usr/share/qt5.9.6/plugins/platforms/../../lib/libQt5XcbQpa.so.5
    #37 0xb577cea9 in QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #38 0xb577d304 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #39 0xb57864a9 in QCoreApplication::exec() () from /usr/share/qt5.9.6/lib/libQt5Core.so.5
    #40 0xb6125ef4 in QGuiApplication::exec() () from /usr/share/qt5.9.6/lib/libQt5Gui.so.5
    #41 0xb66bf184 in QApplication::exec() () from /usr/share/qt5.9.6/lib/libQt5Widgets.so.5
    #42 0x08060468 in main ()

    Anyone has any idea what could this be caused by?
    Thanks.



  • Hello!

    Add the code below in your main.cpp and run the application in a debug mode:

    Code:

    #ifdef QT_DEBUG
        qputenv("QT_FATAL_WARNINGS", "1");
        qputenv("QT_MESSAGE_PATTERN",
                "Type: %{type}\nProduct Name: %{appname}\nFile: %{file}\nLine: %{line}\nMethod: %{function}\nThreadID: %{threadid}\nThreadPtr: %{qthreadptr}\nMessage: %{message}");
    #endif
    

    OR

    #ifdef QT_DEBUG
        qputenv("QT_FATAL_WARNINGS", "1");
        qSetMessagePattern("Type: %{type}\nProduct Name: %{appname}\nFile: %{file}\nLine: %{line}\nMethod: %{function}\nThreadID: %{threadid}\nThreadPtr: %{qthreadptr}\nMessage: %{message}");
    #endif
    

    It should display more information about the crashes. Happy coding!



  • @Cobra91151
    In that case, can't the first one be done just by setting the environment variables and running the application, without code changing/recompiling?

    Oh, do you mean the OP will need to recompile to have a debug version?



  • @JonB

    It is better to run this code in a debug mode. Running in a release mode could display different results.



  • Thanks for the reply, I'll give it a try.


Log in to reply