Bug 332426

Summary: Kate crashes when editing c++ files after mode change to "Normal"
Product: kate Reporter: Eugene Shalygin <eugene.shalygin+bugzilla.kde>
Component: partAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: franciscoadriansanchez, i.zaufi, l.jirkovsky, philippe.sigaud, ravishankar, samuel.d.flis
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In: 4.13.2

Description Eugene Shalygin 2014-03-22 01:20:40 UTC
Afer changing mode of  any C++ file to "normal", kate crashes on any characjter insertion/deletion 

Kate Part
Version 3.7
Using KDE Development Platform 4.12.95

Reproducible: Always

Steps to Reproduce:
1. Open C++ file
2. Change mode to "Normal"
3. Attempt to edit the file
Actual Results:  
Kate crashes


ASSERT: "0" in file katepart-4.12.95/work/katepart-4.12.95/part/syntax/katehighlight.h, line 275

Application: Kate (kate), signal: Aborted
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f0816718780 (LWP 13705))]

Thread 1 (Thread 0x7f0816718780 (LWP 13705)):
[KCrash Handler]
#5  0x00007f0816386209 in raise () from /lib64/libc.so.6
#6  0x00007f0816387568 in abort () from /lib64/libc.so.6
#7  0x00007f0814853d74 in qt_message_output(QtMsgType, char const*) () from /usr/lib64/qt4/libQtCore.so.4
#8  0x00007f0814853ed9 in qt_message(QtMsgType, char const*, __va_list_tag*) () from /usr/lib64/qt4/libQtCore.so.4
#9  0x00007f08148546e4 in qFatal(char const*, ...) () from /usr/lib64/qt4/libQtCore.so.4
#10 0x00007f0809df0208 in KateDocument::defStyleNum(int, int) () from /usr/lib64/libkatepartinterfaces.so.4
#11 0x00007f0809e1a939 in KateScriptDocument::isString(int, int) () from /usr/lib64/libkatepartinterfaces.so.4
#12 0x00007f0809d8b9d5 in KateScriptDocument::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) [clone .part.42] () from /usr/lib64/libkatepartinterfaces.so.4
#13 0x00007f0809d8cad3 in KateScriptDocument::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib64/libkatepartinterfaces.so.4
#14 0x00007f0809a2425d in QScript::callQtMethod(QTJSC::ExecState*, QMetaMethod::MethodType, QObject*, QTJSC::ArgList const&, QMetaObject const*, int, bool) () from /usr/lib64/qt4/libQtScript.so.4
#15 0x00007f0809a25409 in QScript::QtFunction::execute(QTJSC::ExecState*, QTJSC::JSValue, QTJSC::ArgList const&) () from /usr/lib64/qt4/libQtScript.so.4
#16 0x00007f0809a25699 in QScript::QtFunction::call(QTJSC::ExecState*, QTJSC::JSObject*, QTJSC::JSValue, QTJSC::ArgList const&) () from /usr/lib64/qt4/libQtScript.so.4
#17 0x00007f080992b9f8 in QTJSC::NativeFuncWrapper::operator()(QTJSC::ExecState*, QTJSC::JSObject*, QTJSC::JSValue, QTJSC::ArgList const&) const () from /usr/lib64/qt4/libQtScript.so.4
#18 0x00007f0809909bb0 in cti_op_call_NotJSFunction () from /usr/lib64/qt4/libQtScript.so.4
#19 0x00007f077ffede90 in ?? ()
#20 0x0000000000000000 in ?? ()
Comment 1 Jekyll Wu 2014-03-22 06:36:12 UTC

*** This bug has been marked as a duplicate of bug 328271 ***
Comment 2 Eugene Shalygin 2014-03-22 08:16:43 UTC
disagree: here the version is 4.12.95, i.e. after fix for #328271 has been applied. Shall I reopen this bug or ask for reopening #328271 ?
Comment 3 Eugene Shalygin 2014-03-22 08:19:44 UTC
It seem like not any inserted character leads to crash, but "." always does.

Thread 1 (Thread 0x7f8136031780 (LWP 21480)):
[KCrash Handler]
#5  0x00007f813abdb209 in raise () from /lib64/libc.so.6
#6  0x00007f813abdc568 in abort () from /lib64/libc.so.6
#7  0x00007f813c188d74 in qt_message_output(QtMsgType, char const*) () from /usr/lib64/qt4/libQtCore.so.4
#8  0x00007f813c188ed9 in qt_message(QtMsgType, char const*, __va_list_tag*) () from /usr/lib64/qt4/libQtCore.so.4
#9  0x00007f813c1896e4 in qFatal(char const*, ...) () from /usr/lib64/qt4/libQtCore.so.4
#10 0x00007f8128ac996b in contextNum (n=0, this=0x13e7350) at /usr/src/debug/kde-base/katepart-4.12.95/katepart-4.12.95/part/syntax/katehighlight.h:275
#11 KateDocument::defStyleNum (this=0x3e6e180, line=<optimized out>, column=column@entry=21) at /usr/src/debug/kde-base/katepart-4.12.95/katepart-4.12.95/part/document/katedocument.cpp:5486
#12 0x00007f8128af2ef3 in KateScriptDocument::defStyleNum (this=this@entry=0x40df480, line=<optimized out>, column=column@entry=21) at /usr/src/debug/kde-base/katepart-4.12.95/katepart-4.12.95/part/script/katescriptdocument.cpp:51
#13 0x00007f8128af2f73 in KateScriptDocument::isString (this=this@entry=0x40df480, line=<optimized out>, column=column@entry=21) at /usr/src/debug/kde-base/katepart-4.12.95/katepart-4.12.95/part/script/katescriptdocument.cpp:83
#14 0x00007f8128af2fa9 in KateScriptDocument::isString (this=0x40df480, cursor=...) at /usr/src/debug/kde-base/katepart-4.12.95/katepart-4.12.95/part/script/katescriptdocument.cpp:89
#15 0x00007f8128a69e14 in KateScriptDocument::qt_static_metacall (_o=0x40df480, _c=21480, _c@entry=QMetaObject::InvokeMetaMethod, _id=91, _a=0x7fff7167eaf0) at /usr/src/debug/kde-base/katepart-4.12.95/katepart-4.12.95_build/part/moc_katescriptdocument.cpp:407
#16 0x00007f8128a69fc5 in KateScriptDocument::qt_metacall (this=0x40df480, _c=QMetaObject::InvokeMetaMethod, _id=91, _a=0x7fff7167eaf0) at /usr/src/debug/kde-base/katepart-4.12.95/katepart-4.12.95_build/part/moc_katescriptdocument.cpp:467
#17 0x00007f813227a25d in QScript::callQtMethod(QTJSC::ExecState*, QMetaMethod::MethodType, QObject*, QTJSC::ArgList const&, QMetaObject const*, int, bool) () from /usr/lib64/qt4/libQtScript.so.4
#18 0x00007f813227b409 in QScript::QtFunction::execute(QTJSC::ExecState*, QTJSC::JSValue, QTJSC::ArgList const&) () from /usr/lib64/qt4/libQtScript.so.4
#19 0x00007f813227b699 in QScript::QtFunction::call(QTJSC::ExecState*, QTJSC::JSObject*, QTJSC::JSValue, QTJSC::ArgList const&) () from /usr/lib64/qt4/libQtScript.so.4
#20 0x00007f81321819f8 in QTJSC::NativeFuncWrapper::operator()(QTJSC::ExecState*, QTJSC::JSObject*, QTJSC::JSValue, QTJSC::ArgList const&) const () from /usr/lib64/qt4/libQtScript.so.4
#21 0x00007f813215fbb0 in cti_op_call_NotJSFunction () from /usr/lib64/qt4/libQtScript.so.4
#22 0x00007f80a3414e90 in ?? ()
#23 0x0000000000000230 in ?? ()
#24 0x00007f80a1387480 in ?? ()
#25 0x00007f800000000d in ?? ()
#26 0xffff000000000002 in ?? ()
#27 0x00007f80a13853c0 in ?? ()
#28 0x0000000000000004 in ?? ()
#29 0x0000000000000000 in ?? ()
Comment 4 Alex Turbov 2014-04-18 13:20:26 UTC
kate 3.13.0 (compiled from sources on gentoo) can't reproduce...
can you confirm?
Comment 5 Eugene Shalygin 2014-04-19 12:11:17 UTC
Yes. It is my fault that the original bug description is incomplete: one has also set identation mode to C++/Boost.
Therefore:
1. Open a C++ file
2. Check that the mode is "C++"
3. Check that identation mode is "C++/Boost"
2. Change mode to "Normal"
3. Try to insert "."
Comment 6 Alex Turbov 2014-04-21 15:32:41 UTC
confirm!

brief investigation reveals that the problem is easy to reproduce for any indenter w/ 'indent-languages' property set and which calls isString(), isComment() or any other attributes related function. Setting mode to 'Normal' for that indenters should lead to switch indentation mode as well because no styles is available after that (so calling isString() for example leads to ASSERT at katehighlight.h:275).
Comment 7 Alex Turbov 2014-04-21 16:18:29 UTC
the bug fix is submitted to review board: https://git.reviewboard.kde.org/r/117678/
Comment 8 ravishankar 2014-05-08 11:19:21 UTC
Same problem. Is the patch going to be accepted?
Comment 9 Alex Turbov 2014-05-13 02:21:01 UTC
*** Bug 334503 has been marked as a duplicate of this bug. ***
Comment 10 Alex Turbov 2014-05-13 21:27:53 UTC
Git commit 0b05dbdd0cef249a5ac551ad33edb2335ab0b607 by Alex Turbov.
Committed on 13/05/2014 at 21:23.
Pushed by turbov into branch 'master'.

add "style" attribute to C++ syntax files, so C++ indenter will be disabled
when mode set to "Normal", because latter calls isComment() and isString()
and that leads to assert.

M  +1    -0    part/script/data/indentation/cppstyle.js
M  +2    -1    part/syntax/data/cpp.xml
M  +2    -1    part/syntax/data/isocpp.xml

http://commits.kde.org/kate/0b05dbdd0cef249a5ac551ad33edb2335ab0b607
Comment 11 Dominik Haumann 2014-06-04 11:04:32 UTC
*** Bug 328271 has been marked as a duplicate of this bug. ***
Comment 12 Dominik Haumann 2014-06-04 11:06:47 UTC
*** Bug 334248 has been marked as a duplicate of this bug. ***
Comment 13 Dominik Haumann 2014-06-04 11:12:37 UTC
Git commit ff973d7f15a078759599c66d4c4731dbb455449d by Dominik Haumann, on behalf of Alex Turbov.
Committed on 13/05/2014 at 21:23.
Pushed by dhaumann into branch 'KDE/4.13'.

add "style" attribute to C++ syntax files, so C++ indenter will be disabled

backport: when mode set to "Normal", because latter calls isComment() and isString() and that leads to assert.

@Alex: Hope I backported this correctly.
CCMAIL: i.zaufi@gmail.com

M  +1    -0    part/script/data/indentation/cppstyle.js
M  +1    -0    part/syntax/data/cpp.xml

http://commits.kde.org/kate/ff973d7f15a078759599c66d4c4731dbb455449d
Comment 14 Dominik Haumann 2014-06-04 11:24:03 UTC
Still missing: proper port to ktexteditor.git.
Comment 15 Lukas Jirkovsky 2014-06-10 21:07:05 UTC
*** Bug 335368 has been marked as a duplicate of this bug. ***