Crash while updating QLineEdit , calling setText

Denis Ryndine dry at embsys-soft.com.au
Fri Oct 30 02:05:12 GMT 2020


Hello,

Have a bug somewhere, which terminates in QtLibrary.

My Python script calls setText( with string )  . Mostly this works in
many places, but one place I update it at a very high rate and this is
where it's crashing. The slower updates do not seem to cause this.

To try fix/debug this, I've built qt5 lib locally and pyqt5 locally.
My system coredump information generates this backtrace of the thread
which brings Python down:

  Stack trace of thread 46823:
                #0  0x00007f6c1cea9625 raise (libc.so.6)
                #1  0x00007f6c1ce928d9 abort (libc.so.6)
                #2  0x00007f6c0ed8171c qt_message_fatal (libQt5Core.so.5)
                #3  0x00007f6c0ed7dc2e _ZNK14QMessageLogger5fatalEPKcz
(libQt5Core.so.5)
                #4  0x00007f6c0ed75324 _Z9qt_assertPKcS0_i (libQt5Core.so.5)
                #5  0x00007f6c0bc4ceb1 addNextCluster (libQt5Gui.so.5)
                #6  0x00007f6c0bc4dd70 _ZN9QTextLine13layout_helperEi
(libQt5Gui.so.5)
                #7  0x00007f6c0bc4c673 _ZN9QTextLine13setNumColumnsEi
(libQt5Gui.so.5)
                #8  0x00007f6c0bc4949b _ZN11QTextLayout9endLayoutEv
(libQt5Gui.so.5)
                #9  0x00007f6c0a94994e
_ZNK18QWidgetLineControl14redoTextLayoutEv (libQt5Widgets.so.5)
                #10 0x00007f6c0a949dd7
_ZN18QWidgetLineControl17updateDisplayTextEb (libQt5Widgets.so.5)
                #11 0x00007f6c0a94ba4f
_ZN18QWidgetLineControl12finishChangeEibb (libQt5Widgets.so.5)
                #12 0x00007f6c0a94bd9a
_ZN18QWidgetLineControl15internalSetTextERK7QStringib
(libQt5Widgets.so.5)
                #13 0x00007f6c0a93fb07
_ZN18QWidgetLineControl7setTextERK7QString (libQt5Widgets.so.5)
                #14 0x00007f6c0a93d760
_ZN16QLineEditPrivate7setTextERK7QString (libQt5Widgets.so.5)
                #15 0x00007f6c0a941afd
_ZN9QLineEdit7setTextERK7QString (libQt5Widgets.so.5)
                #16 0x00007f6c0b158d2f meth_QLineEdit_setText (QtWidgets.so)
                #17 0x00007f6c1cc2a68e
_PyMethodDef_RawFastCallKeywords (libpython3.7m.so.1.0)
                #18 0x00007f6c1cc2a7c3 _PyCFunction_FastCallKeywords
(libpython3.7m.so.1.0)
                #19 0x00007f6c1cc61793 call_function (libpython3.7m.so.1.0)
                #20 0x00007f6c1cc9cd3a _PyEval_EvalFrameDefault
(libpython3.7m.so.1.0)
                #21 0x00007f6c1cc4f89a function_code_fastcall
(libpython3.7m.so.1.0)
                #22 0x00007f6c1cc23696 _PyObject_Call_Prepend
(libpython3.7m.so.1.0)
                #23 0x00007f6c1cc4ffbe PyObject_Call (libpython3.7m.so.1.0)
                #24 0x00007f6c1cc99ae3 do_call_core (libpython3.7m.so.1.0)
                #25 0x00007f6c1cc4f222 function_code_fastcall
(libpython3.7m.so.1.0)
                #26 0x00007f6c1cc6167f call_function (libpython3.7m.so.1.0)
                #27 0x00007f6c1cc984a0 _PyEval_EvalFrameDefault
(libpython3.7m.so.1.0)
                #28 0x00007f6c1cc4f222 function_code_fastcall
(libpython3.7m.so.1.0)
                #29 0x00007f6c1cc6167f call_function (libpython3.7m.so.1.0)
                #30 0x00007f6c1cc984a0 _PyEval_EvalFrameDefault
(libpython3.7m.so.1.0)
                #31 0x00007f6c1cc4f89a function_code_fastcall
(libpython3.7m.so.1.0)
                #32 0x00007f6c1cc23696 _PyObject_Call_Prepend
(libpython3.7m.so.1.0)
                #33 0x00007f6c1cc4ffbe PyObject_Call (libpython3.7m.so.1.0)
                #34 0x00007f6c1cd27e46 t_bootstrap (libpython3.7m.so.1.0)
                #35 0x00007f6c1cca8114 pythread_wrapper (libpython3.7m.so.1.0)
                #36 0x00007f6c1cb064e2 start_thread (libpthread.so.0)
                #37 0x00007f6c1cf6e6c3 __clone (libc.so.6)

Trying to  look into the core dumb with gdb :

#0  0x00007f6c1cea9625 in raise () from /lib64/libc.so.6
#1  0x00007f6c1ce928d9 in abort () from /lib64/libc.so.6
#2  0x00007f6c0ed8171c in qt_message_fatal (context=..., message=...)
at /devel2/source/qt5/qtbase/src/corelib/global/qlogging.cpp:1914
#3  0x00007f6c0ed7dc2e in QMessageLogger::fatal (this=0x7f6bf4a85d00,
msg=0x7f6c0f113f28 "ASSERT: \"%s\" in file %s, line %d") at
/devel2/source/qt5/qtbase/src/corelib/global/qlogging.cpp:893
#4  0x00007f6c0ed75324 in qt_assert (assertion=0x7f6c0c0208c0 "(pos ==
end && glyphPosition == current.num_glyphs) || logClusters[pos] ==
glyphPosition", file=0x7f6c0c0206b8
"/devel2/source/qt5/qtbase/src/gui/text/qtextlayout.cpp", line=1796)
    at /devel2/source/qt5/qtbase/src/corelib/global/qglobal.cpp:3358
#5  0x00007f6c0bc4ceb1 in addNextCluster (pos=@0x7f6bf4a85ea0: 19,
end=0, line=..., glyphCount=@0x7f6bf4a85e98: 18, current=...,
logClusters=0x7f6bd402bc98, glyphs=..., clusterWidth=0x7f6bf4a85dcc)
    at /devel2/source/qt5/qtbase/src/gui/text/qtextlayout.cpp:1796
#6  0x00007f6c0bc4dd70 in QTextLine::layout_helper
(this=0x7f6bf4a861a0, maxGlyphs=2147483647) at
/devel2/source/qt5/qtbase/src/gui/text/qtextlayout.cpp:1965
#7  0x00007f6c0bc4c673 in QTextLine::setNumColumns
(this=0x7f6bf4a861a0, numColumns=2147483647) at
/devel2/source/qt5/qtbase/src/gui/text/qtextlayout.cpp:1621
#8  0x00007f6c0bc4949b in QTextLayout::endLayout (this=0x55a95e6ff548)
at /devel2/source/qt5/qtbase/src/gui/text/qtextlayout.cpp:678
#9  0x00007f6c0a94994e in QWidgetLineControl::redoTextLayout
(this=0x55a95e6ff470) at
/devel2/source/qt5/qtbase/src/widgets/widgets/qwidgetlinecontrol.cpp:79
#10 0x00007f6c0a949dd7 in QWidgetLineControl::updateDisplayText
(this=0x55a95e6ff470, forceUpdate=false) at
/devel2/source/qt5/qtbase/src/widgets/widgets/qwidgetlinecontrol.cpp:136
#11 0x00007f6c0a94ba4f in QWidgetLineControl::finishChange
(this=0x55a95e6ff470, validateFromState=-1, update=true, edited=false)
at /devel2/source/qt5/qtbase/src/widgets/widgets/qwidgetlinecontrol.cpp:729
#12 0x00007f6c0a94bd9a in QWidgetLineControl::internalSetText
(this=0x55a95e6ff470, txt=..., pos=-1, edited=false) at
/devel2/source/qt5/qtbase/src/widgets/widgets/qwidgetlinecontrol.cpp:772
#13 0x00007f6c0a93fb07 in QWidgetLineControl::setText
(this=0x55a95e6ff470, txt=...) at
../../include/QtWidgets/5.15.2/QtWidgets/private/../../../../../../../qt5/qtbase/src/widgets/widgets/qwidgetlinecontrol_p.h:251
#14 0x00007f6c0a93d760 in QLineEditPrivate::setText
(this=0x55a95e5529a0, text=...) at
/devel2/source/qt5/qtbase/src/widgets/widgets/qlineedit_p.cpp:277
#15 0x00007f6c0a941afd in QLineEdit::setText (this=0x55a95ea4d110,
text=...) at /devel2/source/qt5/qtbase/src/widgets/widgets/qlineedit.cpp:318
#16 0x00007f6c0b158d2f in meth_QLineEdit_setText () from
/usr/lib64/python3.7/site-packages/PyQt5/QtWidgets.so
#17 0x00007f6c1cc2a68e in _PyMethodDef_RawFastCallKeywords
(method=<optimized out>, self=<QLineEdit at remote 0x7f6c0990c550>,
args=0x7f6bd4000f90, nargs=<optimized out>, kwnames=<optimized out>)
    at /usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:697
#18 0x00007f6c1cc2a7c3 in _PyCFunction_FastCallKeywords
(func=<built-in method setText of QLineEdit object at remote
0x7f6c0990c550>, args=<optimized out>, nargs=<optimized out>,
kwnames=<optimized out>)
    at /usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:732
#19 0x00007f6c1cc61793 in call_function (pp_stack=0x7f6bf4a86610,
oparg=<optimized out>, kwnames=0x0) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Python/ceval.c:4568
#20 0x00007f6c1cc9cd3a in _PyEval_EvalFrameDefault (f=<optimized out>,
throwflag=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Python/ceval.c:3093
#21 0x00007f6c1cc4f89a in function_code_fastcall (globals=<optimized
out>, nargs=2, args=<optimized out>, co=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:322
#22 _PyFunction_FastCallDict (func=<optimized out>,
args=0x7f6bf4a86770, nargs=2, kwargs=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:322
#23 0x00007f6c1cc23696 in _PyObject_Call_Prepend (callable=<function
at remote 0x7f6c098f5710>, obj=<optimized out>, args=('gui: widget
updater',), kwargs={}) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:906
#24 0x00007f6c1cc4ffbe in PyObject_Call (callable=<method at remote
0x7f6c0f97a320>, args=<optimized out>, kwargs=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:245
#25 0x00007f6c1cc99ae3 in do_call_core (kwdict={}, callargs=('gui:
widget updater',), func=<method at remote 0x7f6c0f97a320>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Python/ceval.c:4645
#26 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized
out>) at /usr/src/debug/python3-3.7.9-1.fc31.x86_64/Python/ceval.c:3191
#27 0x00007f6c1cc4f222 in function_code_fastcall (globals=<optimized
out>, nargs=1, args=<optimized out>, co=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:408
#28 _PyFunction_FastCallKeywords (func=<optimized out>,
stack=0x7f6bd4000d10, nargs=1, kwnames=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:408
#29 0x00007f6c1cc6167f in call_function (pp_stack=0x7f6bf4a86aa0,
oparg=<optimized out>, kwnames=0x0) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Python/ceval.c:4616
#30 0x00007f6c1cc984a0 in _PyEval_EvalFrameDefault (f=<optimized out>,
throwflag=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Python/ceval.c:3110
#31 0x00007f6c1cc4f222 in function_code_fastcall (globals=<optimized
out>, nargs=1, args=<optimized out>, co=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:408
#32 _PyFunction_FastCallKeywords (func=<optimized out>,
stack=0x7f6c037ed1c8, nargs=1, kwnames=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:408
#33 0x00007f6c1cc6167f in call_function (pp_stack=0x7f6bf4a86c90,
oparg=<optimized out>, kwnames=0x0) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Python/ceval.c:4616
#34 0x00007f6c1cc984a0 in _PyEval_EvalFrameDefault (f=<optimized out>,
throwflag=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Python/ceval.c:3110
#35 0x00007f6c1cc4f89a in function_code_fastcall (globals=<optimized
out>, nargs=1, args=<optimized out>, co=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:322
#36 _PyFunction_FastCallDict (func=<optimized out>,
args=0x7f6bf4a86df0, nargs=1, kwargs=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:322
#37 0x00007f6c1cc23696 in _PyObject_Call_Prepend (callable=<function
at remote 0x7f6c0f7263b0>, obj=<optimized out>, args=(), kwargs=0x0)
at /usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:906
#38 0x00007f6c1cc4ffbe in PyObject_Call (callable=<method at remote
0x7f6c0f89a5a0>, args=<optimized out>, kwargs=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Objects/call.c:245
#39 0x00007f6c1cd27e46 in t_bootstrap
(boot_raw=boot_raw at entry=0x7f6c099648a0) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Modules/_threadmodule.c:994
#40 0x00007f6c1cca8114 in pythread_wrapper (arg=<optimized out>) at
/usr/src/debug/python3-3.7.9-1.fc31.x86_64/Python/thread_pthread.h:174
#41 0x00007f6c1cb064e2 in start_thread () from /lib64/libpthread.so.0
#42 0x00007f6c1cf6e6c3 in clone () from /lib64/libc.so.6

Looks like an assert from from frame 5;  if I poke there:
frame 5
#5  0x00007f6c0bc4ceb1 in addNextCluster (pos=@0x7f6bf4a85ea0: 19,
end=0, line=..., glyphCount=@0x7f6bf4a85e98: 18, current=...,
logClusters=0x7f6bd402bc98, glyphs=..., clusterWidth=0x7f6bf4a85dcc)
    at /devel2/source/qt5/qtbase/src/gui/text/qtextlayout.cpp:1796
1796     Q_ASSERT((pos == end && glyphPosition == current.num_glyphs)
|| logClusters[pos] == glyphPosition);

info locals
glyphPosition = 19
clusterWid = {val = 9079}
(gdb) info args
pos = @0x7f6bf4a85ea0: 19
end = 0
line = @0x7f6bf4a85e10: {descent = {val = 192}, ascent = {val = 768},
leading = {val = -64}, x = {val = 0}, y = {val = 0}, width = {val =
0}, textWidth = {val = 9314}, textAdvance = {val = 0}, from = 0,
trailingSpaces = 0, length = 19, justified = 0,
  gridfitted = 0, hasTrailingSpaces = 0, leadingIncluded = 0}
glyphCount = @0x7f6bf4a85e98: 18
current = @0x7f6bd40391c8: {position = 0, analysis = {script = 3,
flags = 0, bidiFlags = 0, bidiLevel = 0, bidiDirection = QChar::DirL},
num_glyphs = 0, descent = {val = 192}, ascent = {val = 768}, leading =
{val = -64}, width = {val = 0},
  glyph_data_offset = 0}
logClusters = 0x7f6bd402bc98
glyphs = @0x7f6bf4a85e68: {offsets = 0x7f6bd402bcc0, glyphs =
0x7f6bd402bdc0, advances = 0x7f6bd402be40, justifications =
0x7f6bd402bec0, attributes = 0x7f6bd402bf40, numGlyphs = 19}
clusterWidth = 0x7f6bf4a85dcc

And here I'm not sure : is my bad Python script manages to crash due
to passing some bad argument to setText (which is just string , no
other args ) or is the problem happening lower down in PyQt5 or Qt5
library?


More information about the PyQt mailing list