Bug 385399 - Sudden application (kate/kwrite/krusader/kdevelop) crash when hitting ENTER in certain lines in a C file
Summary: Sudden application (kate/kwrite/krusader/kdevelop) crash when hitting ENTER i...
Status: RESOLVED DUPLICATE of bug 384404
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 17.08.1
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-05 13:30 UTC by Péter Ujfalusi
Modified: 2017-11-05 11:01 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
C file to reproduce the crash (579 bytes, text/x-csrc)
2017-10-05 13:30 UTC, Péter Ujfalusi
Details
Backtrace (2.68 KB, text/plain)
2017-10-07 22:13 UTC, Mark Olah
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Péter Ujfalusi 2017-10-05 13:30:41 UTC
Created attachment 108187 [details]
C file to reproduce the crash

Hi,

recently I have been experiencing sudden crashes with all KDE/Plasma text editors using Kate backend.

The crash happens when working with C files, if the same file is copied to a new kwrite window the crash will not happen, so it might be connected to syntax highlight as well.

I have experienced with different lines/context triggering the crash and I see no correlation between them.

I have attached 'blah.c' and if I hit ENTER at the end of the:
	d->sglen = buf_len / period_len;
line, all kate based editor will crash.

I tried to recompile the dependencies, but still did not get any useful backtrace for the crash.

This crash is pretty random in a way that the editors will not crash most of the time, but it is consistently crashing at certain lines.
Comment 1 Darren Lissimore 2017-10-06 06:46:50 UTC
Need more details? 
Which Distro? which KDE versions?
How repeatable -- every 1 in 10 tries ? 1 in 100 tries ? 1 in 500?
What are your syntax-highlighting settings? those may help if it's an issue with the highlighting ..


Loaded the file under kate and kwrite in KDE-Neon fully updated as of last night;
Kate -version 17.11.70

no issues found with a quick test set of 500 tries of:
1) loading file
2) moving to line end of d->sglen = buf_len / period_len;
3) hitting enter when there.
Comment 2 Péter Ujfalusi 2017-10-06 07:07:37 UTC
Darren,

Distro: Gentoo (~amd64)
Kate Part: 5.38.0
Kate: 17.08.1
Kwrite: 17.08.1
Krusader: 2.6.0
KDevelop: 5.1.2

KDE Frameworks 5.38.0
Qt 5.7.1 (built against 5.7.1)

I have not changed the highlighting preferences, not for Source/C for sure, I might have modified things for python.

I can reproduce it with the 'blah.c' 100/100.

If I recall correctly the editors started to crash more frequently after upgrading to 17.08.1, I have faint recollection of a crash with 17.08.1. Earlier (<=17.04.3) I don't think I have seen this.

Out of desperation I have rebuilt everything related to the editors:
emerge -1 --exclude app-office/libreoffice -aev kwrite krusader

but it did not helped.

From Kate this is the backtrace I get (which is not really useful):
Application: Kate (kate), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f2510b83240 (LWP 10332))]

Thread 3 (Thread 0x7f2504e83700 (LWP 10334)):
#0  0x00007f25155a5e99 in g_mutex_lock () from /usr/lib64/libglib-2.0.so.0
#1  0x00007f251555fbf9 in g_main_context_prepare () from /usr/lib64/libglib-2.0.so.0
#2  0x00007f251556063b in ?? () from /usr/lib64/libglib-2.0.so.0
#3  0x00007f251556082c in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#4  0x00007f251ae93dcb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#5  0x00007f251ae4513a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#6  0x00007f251acaa5a3 in QThread::exec() () from /usr/lib64/libQt5Core.so.5
#7  0x00007f251ef632a5 in ?? () from /usr/lib64/libQt5DBus.so.5
#8  0x00007f251acae8fc in ?? () from /usr/lib64/libQt5Core.so.5
#9  0x00007f25174b7637 in start_thread () from /lib64/libpthread.so.0
#10 0x00007f251a245d2f in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7f250da30700 (LWP 10333)):
#0  0x00007f251a23a97d in poll () from /lib64/libc.so.6
#1  0x00007f25178df85f in ?? () from /usr/lib64/libxcb.so.1
#2  0x00007f25178e15e9 in xcb_wait_for_event () from /usr/lib64/libxcb.so.1
#3  0x00007f25105cea89 in ?? () from /usr/lib64/libQt5XcbQpa.so.5
#4  0x00007f251acae8fc in ?? () from /usr/lib64/libQt5Core.so.5
#5  0x00007f25174b7637 in start_thread () from /lib64/libpthread.so.0
#6  0x00007f251a245d2f in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f2510b83240 (LWP 10332)):
[KCrash Handler]
#6  0x00007f24fce15c79 in ?? ()
#7  0x00007f24f8d5a478 in ?? ()
#8  0x0003200000000000 in ?? ()
#9  0x00007f24f8d5a3f8 in ?? ()
#10 0x00007ffd9d6db370 in ?? ()
#11 0x0000000003285fc0 in ?? ()
#12 0x0000000003285fc0 in ?? ()
#13 0x00007f24f8d5a498 in ?? ()
#14 0x00007f24f8d5a490 in ?? ()
#15 0x00007f24f8d5a3f8 in ?? ()
#16 0x00007f2519f196cb in ?? () from /usr/lib64/libQt5Qml.so.5
#17 0x00007f2519f7fad0 in QV4::Runtime::callActivationProperty(QV4::ExecutionEngine*, int, QV4::CallData*) () from /usr/lib64/libQt5Qml.so.5
#18 0x00007f250c0009f2 in ?? ()
#19 0x0000000000000000 in ?? ()

Tried gdb as well, but not much help from it either, I can not pin-point the library I need to rebuild with debug.
Comment 3 Péter Ujfalusi 2017-10-07 06:44:57 UTC
I'm not that familiar with debugging KDE/Plasma, but I have cloned kate and ktexteditor and I can reproduce the crash using those.

The crash happens at ktexteditor's 
src/script/kateindentscript.cpp, line 75:
    QJSValue result = indentFunction.call(arguments);

I can not easily revert the patch adding it (878797830dbd Switch from QtScript to QtQml) but I don't see anything fishy in the commit itself.

I'm not sure how to continue, I guess I should somehow debug qtdeclarative.
Comment 4 Darren Lissimore 2017-10-07 07:55:34 UTC
Well - the closest I could easily get to your setup; 
Distro: Ubuntu (~amd64)
Kate: 17.08.1
Kwrite: 17.08.1
KDE Frameworks 5.39.0
Qt 5.9.1

Yet no luck reproducing the crash. 
Note the Qt differences are large - your at 5.7.1 - vs my 5.9.1 
Without a spare build machine my reproduction efforts are stalled.
Comment 5 Mark Olah 2017-10-07 22:09:55 UTC
I can confirm Peter's observed crash, and I have a possible work around

My setup:

Distro: Gentoo (~amd64)
Kate: 17.08.1
Kdevelop: 5.1.2
KDE Frameworks 5.38.0
qtdeclarative: 5.7.1-r1 [jit]

Kate will crash every time on Peter's file as described.  I have had several similar crashed when pasting code in certain file.  I get a slightly different and even more useless backtrace that I am attaching.  It looks like the thread that has crashed has a corrupted stack or something.  I was not able to make progress debugging it until I saw Peter's stack backtrace, which unlike mine mentioned the qtdeclarative package libraries.

On a hunch I re-emerged dev-qt/qtdeclarative adding -jit to use flags and the crash is fixed... so far.

For gentoo users, just add "=dev-qt/qtdeclarative-5.7.1-r1 -jit" to package.use and then run "emerge -1 qtdeclarative"

Let me know if there is any other information that could be of use.
Comment 6 Mark Olah 2017-10-07 22:13:01 UTC
Created attachment 108226 [details]
Backtrace

Largely uninformative backtrace.  Is the stack corrupted??  Not sure why I have 0x0 addr in backtrace.  No better information was available from gdb.
Comment 7 Kåre Särs 2017-10-08 06:24:28 UTC

*** This bug has been marked as a duplicate of bug 384404 ***
Comment 8 Péter Ujfalusi 2017-10-11 06:31:18 UTC
Hi,

just to note: after updating QT to 5.9.2, the bug is gone. So the 5.7.1's qtdeclarative JIT was to blame for the crashes.
Comment 9 Dominik Haumann 2017-11-05 11:01:41 UTC
This is a regression in the indentation in the KTextEditor framework 5.38 and 5.39. This regression was introduced since we switched from the Qt Script to the Qt QML javascript implementation. Unfortunately, the Qt QML implementation still had issues which we did not catch early enough.

The good news is that if you upgrade your Qt version to Qt >= 5.9.1, then this crash is fixed. A workaround will also be available with KDE Frameworks 5.40 which should prevent the crash.

Sorry for the inconvenience!