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

Getting crash in multithreaded environment



  • This is the backtrace. Can somene help me to trace the issue

    program received signal SIGSEGV, Segmentation fault.
    0x00007f38e98e0c31 in QVector<QScriptItem>::operator[] (this=0x0, i=0) at /u/prod/qt/qt4/qt-everywhere-enterprise-src-4.8.6/src/corelib/tools/qvector.h:337
    337	{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range");
    (gdb) up
    #1  0x00007f38e9a30fc3 in QTextLine::cursorToX (this=0x7fff4144d170, cursorPos=0x7fff4144d0c4, edge=QTextLine::Leading)
        at gui/text/qtextlayout.cpp:2513
    2513	    const QScriptItem *si = &eng->layoutData->items[itm];
    (gdb) 
    #2  0x00007f38e9a1eb20 in QTextLine::cursorToX (this=0x7fff4144d170, cursorPos=2, edge=QTextLine::Leading)
        at gui/text/qtextlayout.h:208
    208	    inline qreal cursorToX(int cursorPos, Edge edge = Leading) const { return cursorToX(&cursorPos, edge); }
    (gdb) 
    #3  0x00007f38e9a113ed in QTextControlPrivate::rectForPosition (this=0x7f38dc86df80, position=40) at text/qtextcontrol.cpp:1357
    1357	        qreal x = line.cursorToX(relativePos);
    (gdb) bt
    #0  0x00007f38e98e0c31 in QVector<QScriptItem>::operator[] (this=0x0, i=0) at src/corelib/tools/qvector.h:337
    #1  0x00007f38e9a30fc3 in QTextLine::cursorToX (this=0x7fff4144d170, cursorPos=0x7fff4144d0c4, edge=QTextLine::Leading)
    gui/text/qtextlayout.cpp:2513
    #2  0x00007f38e9a1eb20 in QTextLine::cursorToX (this=0x7fff4144d170, cursorPos=2, edge=QTextLine::Leading)
    gui/text/qtextlayout.h:208
    #3  0x00007f38e9a113ed in QTextControlPrivate::rectForPosition (this=0x7f38dc86df80, position=40) at gui/text/qtextcontrol.cpp:1357
    #4  0x00007f38e9a11f9d in QTextControl::cursorRect (this=0x7f38dcb54b90, cursor=...) at gui/text/qtextcontrol.cpp:2187
    #5  0x00007f38e9a11fd8 in QTextControl::cursorRect (this=0x7f38dcb54b90) at gui/text/qtextcontrol.cpp:2193
    #6  0x00007f38e9a12083 in QTextControl::inputMethodQuery (this=0x7f38dcb54b90, property=Qt::ImMicroFocus)
        at  gui/text/qtextcontrol.cpp:1993
    #7  0x00007f38e9ccc32f in QTextEdit::inputMethodQuery (this=0x7f38dc86de00, property=Qt::ImMicroFocus)
        at gui/widgets/qtextedit.cpp:1677
    #8  0x00007f38e9e7f710 in QXIMInputContext::update (this=0x7f38dcbbe520) at gui/inputmethod/qximinputcontext_x11.cpp:797
    #9  0x00007f38e9747171 in QWidget::updateMicroFocus (this=0x7f38dc86de00) at gui/kernel/qwidget.cpp:11442
    #10 0x00007f38e97549e7 in QWidget::qt_static_metacall (_o=0x7f38dc86de00, _c=QMetaObject::InvokeMetaMethod, _id=21, _a=0x7fff4144d800) at .moc/debug-shared/moc_qwidget.cpp:186
    #11 0x00007f38e7176302 in QMetaObject::activate (sender=0x7f38dcb54b90, m=0x7f38ea39c040, local_signal_index=0, argv=0x0)
        at src/corelib/kernel/qobject.cpp:3545
    #12 0x00007f38e9a0b3c6 in QTextControl::textChanged (this=0x7f38dcb54b90) at .moc/debug-shared/moc_qtextcontrol_p.cpp:254
    #13 0x00007f38e9a17bc3 in QTextControl::qt_static_metacall (_o=0x7f38dcb54b90, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0x7f38d848ad00) at .moc/debug-shared/moc_qtextcontrol_p.cpp:130
    #14 0x00007f38e9a17f97 in QTextControl::qt_metacall (this=0x7f38dcb54b90, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0x7f38d848ad00) at .moc/debug-shared/moc_qtextcontrol_p.cpp:206
    #15 0x00007f38e7161544 in QMetaObject::metacall (object=0x7f38dcb54b90, cl=QMetaObject::InvokeMetaMethod, idx=4, argv=0x7f38d848ad00)
        at /corelib/kernel/qmetaobject.cpp:223
    #16 0x00007f38e71702c6 in QMetaCallEvent::placeMetaCall (this=0x7f38a59c4fb0, object=0x7f38dcb54b90) at /src/corelib/kernel/qobject.cpp:504
    #17 0x00007f38e71751e9 in QObject::event (this=0x7f38dcb54b90, e=0x7f38a59c4fb0) at qt-everywhere-enterprise-src-4.8.6/src/corelib/kernel/qobject.cpp:1200
    #18 0x00007f38e9a0aeeb in QTextControl::event (this=0x7f38dcb54b90, e=0x7f38a59c4fb0) at 
    gui/text/qtextcontrol.cpp:1113
    #19 0x00007f38e96d689f in QApplicationPrivate::notify_helper (this=0x7f38dc84d700, receiver=0x7f38dcb54b90, e=0x7f38a59c4fb0)
        atsrc/gui/kernel/qapplication.cpp:4545
    #20 0x00007f38e96d6ceb in QApplication::notify (this=0x7f38dc916600, receiver=0x7f38dcb54b90, e=0x7f38a59c4fb0)
        at src/gui/kernel/qapplication.cpp:3927
    #21 0x0000000001171d82 in QApplication::notify(QObject*, QEvent*) () at rtld/IDE_standalone_1/main.cxx:183
    #22 0x00007f38e7158ae4 in QCoreApplication::notifyInternal (this=0x7f38dc916600, receiver=0x7f38dcb54b90, event=0x7f38a59c4fb0)
        at /src/corelib/kernel/qcoreapplication.cpp:935
    #23 0x00007f38e715e94b in QCoreApplication::sendEvent (receiver=0x7f38dcb54b90, event=0x7f38a59c4fb0)
        at/src/corelib/kernel/qcoreapplication.h:209
    #24 0x00007f38e7159106 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x7f38dc872080)
        at rc/corelib/kernel/qcoreapplication.cpp:1559
    #25 0x00007f38e7199258 in QEventDispatcherUNIX::processEvents (this=0x7f38dc82b840, flags=...)
        at /corelib/kernel/qeventdispatcher_unix.cpp:905
    ---Type <return> to continue, or q <return> to quit---
    

    [Edit ~aha_1980: Fixed severe typos]



  • @Qt-Enthusiast said in Getting crash in multithreaded environment:

    2513 const QScriptItem *si = &eng->layoutData->items[itm];

    That's your code line? Have you verified itm, layoutData->items, etc?


  • Qt Champions 2017

    In a multithreaded environment you have more than one trace, please provide the additional ones. There's practically no way of knowing what's happening with the other threads by the stack trace of the main one. The suspicious part in what you posted above is actually at the top:

    0x00007f38e98e0c31 in QVector<QScriptItem>::operator[] (this=0x0, i=0)
    

    which'd suggest &eng->layoutData points to nowhere.

    Additionally, are you sure this is at all a threading issue? I'd first make sure that whatever is happening is not happening in single-threaded code.



  • Yes this is threading issue , if we no threaded environment it works fine



  • @Qt-Enthusiast
    Nobody is going to be able to work out from your stack trace what might be going on in your multithreaded code to cause this....



  • how do we solve this problem
    what details I give more ?



  • @Qt-Enthusiast

    Start with explaining what your code is trying to do, and how you are using threads to try to do it. Try to make a minimal piece of code that can reproduce the problem, and share what it does.


Log in to reply