andreikop / enki

A text editor for programmers
http://enki-editor.org
GNU General Public License v2.0
161 stars 38 forks source link

Enki sometimes crashes with SIGSEGV when editing text #225

Closed vi closed 10 years ago

vi commented 10 years ago
PYTHONPATH=/home/vi/src/git/qutepart:/home/vi/src/git/enki gdb -args python /home/vi/src/git/enki/bin/enki
...
Program received signal SIGSEGV, Segmentation fault.
0x00000065 in ?? ()
(gdb) bt
#0  0x00000065 in ?? ()
#1  0xf7977dab in sip_api_get_address () from /usr/lib/python2.7/dist-packages/sip.so
#2  0xf79859c0 in sipOMFindObject () from /usr/lib/python2.7/dist-packages/sip.so
#3  0xf7978dcd in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#4  0xf797acab in sip_api_convert_from_type () from /usr/lib/python2.7/dist-packages/sip.so
#5  0xf6beb1de in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#6  0xf7984043 in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#7  0x0812f4a5 in PyObject_GetAttr ()
#8  0x0813c169 in PyEval_EvalFrameEx ()
#9  0x08145f12 in ?? ()
#10 0x08108352 in ?? ()
#11 0x08177698 in ?? ()
#12 0x08177bef in _PyObject_SlotCompare ()
#13 0x0813231c in ?? ()
#14 0x0813cd11 in PyEval_EvalFrameEx ()
#15 0x0813c974 in PyEval_EvalFrameEx ()
#16 0x0813c974 in PyEval_EvalFrameEx ()
#17 0x08145f12 in ?? ()
#18 0x08108352 in ?? ()
#19 0x08121fc9 in PyEval_CallObjectWithKeywords ()
#20 0xf79843e4 in sip_api_invoke_slot () from /usr/lib/python2.7/dist-packages/sip.so
#21 0xf776a4a5 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtCore.so
#22 0xf776a7f7 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtCore.so
#23 0xf776a8db in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtCore.so
#24 0xf742b157 in QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/i386-linux-gnu/libQtCore.so.4
#25 0xf743965b in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/i386-linux-gnu/libQtCore.so.4
#26 0xf677f805 in QTextDocument::contentsChange(int, int, int) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#27 0xf63391a5 in ?? () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#28 0xf6339308 in ?? () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#29 0xf6367a43 in QTextCursor::insertText(QString const&, QTextCharFormat const&) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#30 0xf6367b9c in QTextCursor::insertText(QString const&) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#31 0xf62fc069 in ?? () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#32 0xf62ffc74 in QTextControl::processEvent(QEvent*, QMatrix const&, QWidget*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#33 0xf62f3a7c in QTextControl::processEvent(QEvent*, QPointF const&, QWidget*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#34 0xf65939ed in QPlainTextEdit::keyPressEvent(QKeyEvent*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#35 0xf6cadbbc in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#36 0x0813c391 in PyEval_EvalFrameEx ()
#37 0x08145f12 in ?? ()
#38 0x08108352 in ?? ()
#39 0x08121fc9 in PyEval_CallObjectWithKeywords ()
#40 0xf797bff0 in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#41 0xf6b5ea76 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#42 0xf6ce063b in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#43 0xf60d8e23 in QWidget::event(QEvent*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#44 0xf64e20fc in QFrame::event(QEvent*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#45 0xf65718cf in QAbstractScrollArea::event(QEvent*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#46 0xf6593181 in QPlainTextEdit::event(QEvent*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#47 0xf6cf1be0 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#48 0xf607e936 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#49 0xf6086386 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#50 0xf6f44c60 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#51 0xf74240ec in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/i386-linux-gnu/libQtCore.so.4
#52 0xf607d01d in ?? () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#53 0xf612d499 in ?? () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#54 0xf612d8a7 in ?? () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#55 0xf6104a53 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#56 0xf61301e4 in ?? () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#57 0xf71f66d3 in g_main_dispatch (context=0x8416200)
    at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:2539
#58 g_main_context_dispatch (context=context@entry=0x8416200)
    at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:3075
#59 0xf71f6a70 in g_main_context_iterate (context=context@entry=0x8416200, block=block@entry=1, dispatch=dispatch@entry=1, 
    self=<error reading variable: Unhandled dwarf expression opcode 0xfa>)
    at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:3146
#60 0xf71f6b51 in g_main_context_iteration (context=0x8416200, may_block=1)
    at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:3207
#61 0xf7453d5f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/i386-linux-gnu/libQtCore.so.4
#62 0xf613029e in ?? () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#63 0xf7422a93 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/i386-linux-gnu/libQtCore.so.4
#64 0xf7422dc9 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/i386-linux-gnu/libQtCore.so.4
#65 0xf7428bee in QCoreApplication::exec() () from /usr/lib/i386-linux-gnu/libQtCore.so.4
#66 0xf607cdc4 in QApplication::exec() () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#67 0xf6efc67e in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#68 0x0813c391 in PyEval_EvalFrameEx ()
#69 0x0813c974 in PyEval_EvalFrameEx ()
#70 0x081447e2 in PyEval_EvalCode ()
#71 0x08144ddf in ?? ()
#72 0x0805d824 in PyRun_FileExFlags ()
#73 0x0805ddf1 in PyRun_SimpleFileExFlags ()
#74 0x0805eb49 in Py_Main ()
#75 0x0805ec28 in main ()

Version:

Version 14.03.0
Uses Qutepart 2.0.0 (with binary parser)

The problem is reproducible now, but the backtrace is not necessary exact (now I see the address #0 0x20202020 in ?? ()).

The problem appears when I type the second character in new identifier, like this:

if (getenv("D

(typing "O" crashes Enki).

If I close the Navigator, Enki behaves normally.

One more observation: messages like

File '/mnt/src/git/openh264/codec/console/dec/src/h264dec.cpp' is not writable

may to affect the crash. The crash may happen when the second of two such messages expires (affecting the window layout a bit).

If I follow other sequence of UI actions (other delays between typed text, closing or not closing bottom messages manually, typing other text in other place) it may fail to reproduce or reproduce later...

vi commented 10 years ago

Seems like it still happens with closed Navigator as well...

vi commented 10 years ago

MALLOC_CHECK_=1 does not help.

andreikop commented 10 years ago

Hi

Could you test it on Enki master + Qutepart master?

vi commented 10 years ago

Updated:

Version 14.03.0
Uses Qutepart 2.1.0 (with binary parser)

Still crashes, the same backtrace.

andreikop commented 10 years ago
vi commented 10 years ago

Reproduced without cParser.so (Uses Qutepart 2.1.0 (with Python parser)), the same backtrace. There are also additional repeated ERROR:qutepart:#pop value is too big 3 unlike with native version.

Shall I try to get debugging symbols for Python and PyQt to make nicer backtrace?

vi commented 10 years ago

I tried installing debugging packages for python and python-qt4; this caused both packages to be upgraded; this in turn caused the bug to stop being reproducible.

Probably the bug was not Enki-specific.

vi commented 10 years ago

Reproduced again, now with debugging packages installed.

Mega-backtrace: https://gist.github.com/vi/cc46cf95cd5b44f7964b

The problem is reproducible even on this small cpp file:

void foo() {
   if (qqq) return;
}

It opens as Enki starts (along of many other files, some of which are not writable), I try typing logger instead lf qqq, and it crashes (not from the first attempt maybe).

If I try the same with Enki started from other user account (with other session) displaying window on the same X server, it does not crash.

vi commented 10 years ago

Another problem while editing C++ code:

Traceback (most recent call last):
  File "/home/vi/src/git/qutepart/qutepart/completer.py", line 469, in _onCompletionListItemSelected
    selectedWord = model.words[index]
IndexError: list index out of range
andreikop commented 10 years ago

The crash: Thank you for the useful backtrace. I haven't reproduced the bug, but committed a bunch of patches, which might fix it. Try to reproduce the bug on Qutepart master.

The exception: I can workaround the bug by adding list range check, but I'd like to understand the problem. Do you have an idea how to reproduce it?

vi commented 10 years ago

I don't know. I was editing the C++ code, the bug triggered instead of showing of code completion window. Maybe the file was incomplete or with syntax errors...

Try to reproduce the bug on Qutepart master.

I'll update it and retry when I see the bug the next time. Now it does not happen.

vi commented 10 years ago

Reproduced again (with older Qutepart). After updating Qutepart it does not crash.

git-bisect points to the fixing commit: hlamer/qutepart@6682f2b5cc5a512fdfca1c782605ed8c1ce218e3 "do not monkeypatch..."

andreikop commented 10 years ago

Cool! Thank you for finding the bug. I'll release v2.1.1