Crash while updating QLineEdit , calling setText

Denis Ryndine dry at embsys-soft.com.au
Fri Oct 30 23:38:10 GMT 2020


Hi Florian,

I started with installing all as standard on my distro - non debug ( i
hope) default system version of qt5 libs,  standard python,  then pip
install PyQt5. Nothing special, no local debug builds.
The script / Python started crashing / core dumping when I started
using my QLineEdits .

Here is few snips from coredump info from those crashes - they not all
end up same :

 Stack trace of thread 83304:
                #0  0x00007fef066ed503 _ZNK11QTextEngine8findItemEii
(libQt5Gui.so.5)
                #1  0x00007fef066ef4a0
_ZN21QTextLineItemIteratorC2EP11QTextEngineiRK7QPointFPKN11QTextLayout11FormatRangeE
(libQt5Gui.so.5)
                #2  0x00007fef066f350c
_ZNK9QTextLine4drawEP8QPainterRK7QPointFPKN11QTextLayout11FormatRangeE
(libQt5Gui.so.5)
                #3  0x00007fef066f4ca6
_ZNK11QTextLayout4drawEP8QPainterRK7QPointFRK7QVectorINS_11FormatRangeEERK6QRectF
(libQt5Gui.so.5)
                ......
                #61 0x00007fef17e3b222 _PyFunction_FastCallKeywords
(libpython3.7m.so.1.0)
                #62 0x00007fef17e4d67f call_function (libpython3.7m.so.1.0)
                #63 0x00007fef17e843f5 _PyEval_EvalFrameDefault
(libpython3.7m.so.1.0)

 Stack trace of thread 79939:
                #0  0x00007f9eb463f625 raise (libc.so.6)
                #1  0x00007f9eb46288d9 abort (libc.so.6)
                #2  0x00007f9ea5571b25 _ZNK14QMessageLogger5fatalEPKcz
(libQt5Core.so.5)
                #3  0x00007f9ea1ba1e44 _ZN14QWidgetPrivateC2Ei.cold
(libQt5Widgets.so.5)
                #4  0x00007f9ea1d05f94
_ZN11QMainWindowC1EP7QWidget6QFlagsIN2Qt10WindowTypeEE
(libQt5Widgets.so.5)
                #5  0x00007f9ea23a0c2d
_ZN14sipQMainWindowC2EP7QWidget6QFlagsIN2Qt10WindowTypeEE
(QtWidgets.so)
                #6  0x00007f9ea23a0d4b init_type_QMainWindow (QtWidgets.so)
                #7  0x00007f9ea6470a38 sipSimpleWrapper_init (sip.so)
                #8  0x00007f9eb43f5cf7 _PyObject_FastCallKeywords
(libpython3.7m.so.1.0)
               .............
                #40 0x00007f9eb44be241 pymain_main (libpython3.7m.so.1.0)
                #41 0x00007f9eb44be3ec _Py_UnixMain (libpython3.7m.so.1.0)
                #42 0x00007f9eb462a1a3 __libc_start_main (libc.so.6)
                #43 0x000055d8f6aee08e _start (python3.7)


Stack trace of thread 83339:
                #0  0x00007f43e843dfff
_ZNK9QTextLine9cursorToXEPiNS_4EdgeE (libQt5Gui.so.5)
                #1  0x00007f43e74912cd
_ZN9QLineEdit10paintEventEP11QPaintEvent (libQt5Widgets.so.5)
                #2  0x00007f43e7b1b1ab
_ZN12sipQLineEdit10paintEventEP11QPaintEvent (QtWidgets.so)
               .........
                #62 0x00007f43f9bccd3a _PyEval_EvalFrameDefault
(libpython3.7m.so.1.0)
                #63 0x00007f43f9b7e370 _PyEval_EvalCodeWithName
(libpython3.7m.so.1.0)


Stack trace of thread 100333:
                #0  0x00007f5c3a81c625 raise (libc.so.6)
                #1  0x00007f5c3a8058d9 abort (libc.so.6)
                #2  0x00007f5c3a8604bf __libc_message (libc.so.6)
                #3  0x00007f5c3a867aac malloc_printerr (libc.so.6)
                #4  0x00007f5c3a868346 unlink_chunk.isra.0 (libc.so.6)
                #5  0x00007f5c3a86bb11 _int_realloc (libc.so.6)
                #6  0x00007f5c3a86cce6 realloc (libc.so.6)
                #7  0x00007f5c28e6b8cc
_ZN11QTextEngine10LayoutData10reallocateEi (libQt5Gui.so.5)
                #8  0x00007f5c28e6ca66
_ZNK11QTextEngine23shapeTextWithHarfbuzzNGERK11QScriptItemPKtiP11QFontEngineRK7QVectorIjEbb
(libQt5Gui.so.5)
                #9  0x00007f5c28e6eee5 _ZNK11QTextEngine9shapeTextEi
(libQt5Gui.so.5)
                #10 0x00007f5c28e6faf9 _ZNK11QTextEngine5shapeEi
(libQt5Gui.so.5)
                #11 0x00007f5c28e7fb6e _ZN9QTextLine13layout_helperEi
(libQt5Gui.so.5)
                #12 0x00007f5c28e80d65 _ZN11QTextLayout9endLayoutEv
(libQt5Gui.so.5)
                #13 0x00007f5c27eda9c8
_ZNK18QWidgetLineControl14redoTextLayoutEv (libQt5Widgets.so.5)
                #14 0x00007f5c27edaba8
_ZN18QWidgetLineControl17updateDisplayTextEb (libQt5Widgets.so.5)
                #15 0x00007f5c27ede04a
_ZN18QWidgetLineControl12finishChangeEibb (libQt5Widgets.so.5)
                #16 0x00007f5c27ede49f
_ZN18QWidgetLineControl15internalSetTextERK7QStringib
(libQt5Widgets.so.5)
                #17 0x00007f5c27ed4f48
_ZN9QLineEdit7setTextERK7QString (libQt5Widgets.so.5)
                #18 0x00007f5c2855890f meth_QLineEdit_setText (QtWidgets.so)
                ........
            #42 0x00007f5c3a69ae46 t_bootstrap (libpython3.7m.so.1.0)
                #43 0x00007f5c3a61b114 pythread_wrapper (libpython3.7m.so.1.0)
                #44 0x00007f5c3a4794e2 start_thread (libpthread.so.0)
                #45 0x00007f5c3a8e16c3 __clone (libc.so.6)


Mostly, all got killed with Signal: 11 (SEGV), the last one was
Signal: 6 (ABRT).   Nothing carries on after these, the app is killed.
That looks like all over the place, if you ask me.   I must be doing
something fundamentally wrong from my Python script that it brings
down entire Python runtime in such way.

I thought, may be I will get some more info by building locally Qt5,
and then PyQt5  - and that was when I've posted my first message to
the board. But now I just get more asserts which sometimes - not
always, often it gets killed before - propagate to my message handler
with FATAL status before being killed.

So here is some traces receive now if I ran it - the traces before
it's killed (most often it's killed before any assert / trace )

Out of memory  in
../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvector.h,
line 709
terminate called without an active exception
Aborted (core dumped)
---------------

python3: hb-shape-plan.cc:394: hb_bool_t
hb_shape_plan_execute(hb_shape_plan_t*, hb_font_t*, hb_buffer_t*,
const hb_feature_t*, unsigned int): Assertion `shape_plan->face_unsafe
== font->face' failed.
--------------

qt_message_handler: line: 1551, func: None(), file:
/devel2/source/qt5/qtbase/src/gui/text/qtextengine.cpp
  FATAL: ASSERT failure in Q_UNREACHABLE(): "Q_UNREACHABLE was
reached", file /devel2/source/qt5/qtbase/src/gui/text/qtextengine.cpp,
line 1551
--------------------------------

qt_message_handler: line: 462, func: None(), file:
../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvector.h
  FATAL: ASSERT failure in QVector<T>::operator[]: "index out of
range", file ../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvector.h,
line 462
--------------------------

About 9 out 10 it's killed before it can trace anything.  Looks wild.
  Something corrupted, loosing memory, or all of the above?

I'm not at any rate have much Python experience, but I'm doing
something really simple in my script,  I'm updating a number of text
edits, as below.

#   Snip ....
    if sdata is not None:
                            # Too high rate crashes Python ???
                            sboxes[2].setText(sdata)
#   ......

Now , the comment about rate is because, it __seems__ i do not get  /
or cannot get often enough the problem to ever have caught it so far.
If the update is few times per second  / say 10 times  asec  I
probably will not get any crashes.

But it bombs out for certain if I try to every ~5  ms and faster.

Denis


On Fri, Oct 30, 2020 at 10:45 PM Florian Bruhin <me at the-compiler.org> wrote:
>
> Hey,
>
> On Fri, Oct 30, 2020 at 01:05:12PM +1100, Denis Ryndine wrote:
> > 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);
> >
> > [...]
> >
> > 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?
>
> Looks like it's the same assertion than mentioned in this Qt bug:
> https://bugreports.qt.io/browse/QTBUG-45077
>
> There it's called a debug-only issue, though. Do you get the same crash
> with a release build of Qt?
>
> Florian
>
> --
> me at the-compiler.org (Mail/XMPP) | https://www.qutebrowser.org
>        https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
>        GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
>              I love long mails! | https://email.is-not-s.ms/


More information about the PyQt mailing list