Bug 397659 - Crash when opening PHP file
Summary: Crash when opening PHP file
Status: RESOLVED FIXED
Alias: None
Product: frameworks-ktexteditor
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-20 14:14 UTC by Kai Uwe Broulik
Modified: 2018-08-20 16:59 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Uwe Broulik 2018-08-20 14:14:27 UTC
Opening a PHP file in Kate makes it crash in Syntax highlighting:

Thread 1 (Thread 0x7f0193cd6800 (LWP 65464)):
[KCrash Handler]
#6  KateHighlighting::applyFormat (this=this@entry=0x557a3ecc4d80, offset=offset@entry=0, length=5, format=...) at ./src/syntax/katehighlight.cpp:261
#7  0x00007f018dbe8201 in KSyntaxHighlighting::AbstractHighlighter::highlightLine (this=this@entry=0x557a3ecc4d80, text=..., state=...) at ./src/lib/abstracthighlighter.cpp:226
#8  0x00007f0193723ebc in KateHighlighting::doHighlight (this=0x557a3ecc4d80, prevLine=<optimized out>, textLine=0x557a3ecc1680, nextLine=nextLine@entry=0x557a3ecc1700, ctxChanged=@0x7ffc1ea46257: false, tabWidth=4) at ./src/syntax/katehighlight.cpp:207
#9  0x00007f01936cab08 in KateBuffer::doHighlight (this=0x557a3e331530, startLine=<optimized out>, endLine=<optimized out>, invalidate=<optimized out>) at ./src/document/katebuffer.cpp:395
#10 0x00007f01936ab183 in KTextEditor::DocumentPrivate::kateTextLine (this=0x557a3e327d50, i=0) at ./src/document/katedocument.cpp:5180
#11 0x00007f019370c524 in KateLineLayout::textLine (this=0x557a3ecc1590, reloadForce=reloadForce@entry=false) at ./src/render/katelinelayout.cpp:69
#12 0x00007f01937051de in KateRenderer::layoutLine (this=0x557a3e891530, lineLayout=..., maxwidth=1006, cacheLayout=<optimized out>) at ./src/render/katerenderer.cpp:1009
#13 0x00007f0193708d79 in KateLayoutCache::line (this=this@entry=0x557a3e896030, realLine=realLine@entry=0, virtualLine=virtualLine@entry=-1) at ./src/render/katelayoutcache.cpp:334
#14 0x00007f0193709ab0 in KateLayoutCache::updateViewCache (this=this@entry=0x557a3e896030, startPos=..., newViewLineCount=newViewLineCount@entry=61, viewLinesScrolled=viewLinesScrolled@entry=0) at ./src/render/katelayoutcache.cpp:192
#15 0x00007f01937439bb in KateViewInternal::doUpdateView (this=0x557a3e594380, changed=<optimized out>, viewLinesScrolled=0) at ./src/view/kateviewinternal.cpp:637
#16 0x00007f0193743c84 in KateViewInternal::updateView (this=0x557a3e594380, changed=<optimized out>, viewLinesScrolled=viewLinesScrolled@entry=0) at ./src/view/kateviewinternal.cpp:611
#17 0x00007f019372ccc6 in KTextEditor::ViewPrivate::updateView (this=0x557a3e88f570, changed=<optimized out>) at ./src/view/kateview.cpp:2044
#18 0x00007f019373ca6f in KTextEditor::ViewPrivate::updateDocumentConfig (this=<optimized out>) at ./src/view/kateview.cpp:1902
#19 0x00007f01936b3c54 in KTextEditor::DocumentPrivate::updateConfig (this=0x557a3e327d50) at ./src/document/katedocument.cpp:4418
#20 0x00007f0193784d1d in KateDocumentConfig::updateConfig (this=0x557a3e2fb2c0) at ./src/utils/kateconfig.cpp:431
#21 0x00007f019377eb30 in KateConfig::configEnd (this=0x557a3e2fb2c0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qarraydata.h:237
#22 KateDocumentConfig::setEncoding (this=this@entry=0x557a3e2fb2c0, encoding=...) at ./src/utils/kateconfig.cpp:937
#23 0x00007f01936c9ec8 in KateBuffer::openFile (this=this@entry=0x557a3e331530, m_file=..., enforceTextCodec=enforceTextCodec@entry=false) at ./src/document/katebuffer.cpp:208
#24 0x00007f01936c22ff in KTextEditor::DocumentPrivate::openFile (this=0x557a3e327d50) at ./src/document/katedocument.cpp:2250
#25 0x00007f019336fad6 in ?? () from /usr/lib/x86_64-linux-gnu/libKF5Parts.so.5
#26 0x00007f0193370961 in KParts::ReadOnlyPart::openUrl(QUrl const&) () from /usr/lib/x86_64-linux-gnu/libKF5Parts.so.5
#27 0x00007f01936aec11 in KTextEditor::DocumentPrivate::openUrl (this=0x557a3e327d50, url=...) at ./src/document/katedocument.cpp:2644
Comment 1 Volker Krause 2018-08-20 14:31:44 UTC
It's an assert in debug builds three lines up already:
ASSERT: "it != m_formatsIdToIndex.end()" in file /k/kde5/src/ktexteditor/src/syntax/katehighlight.cpp, line 258
Comment 2 Christoph Cullmann 2018-08-20 15:12:04 UTC
That means a Format arrives that was not seen for the definition and all its included ones. I thought this was fixed during Akademy.

But yeah, it crashs even with the unit test input :/

I register in the constructor only ids:

id 1
id 2
id 3
id 4
id 5
id 6
id 7
id 8
id 9
id 10
id 11
id 12
id 56
id 57
id 58
id 59
id 60
id 142
id 143
id 144
id 145
id 146
id 147
id 148
id 149
id 150
id 151
id 152
id 153
id 154
id 155
id 156
id 157
id 158
id 159
id 160
id 161
id 162
id 163
id 164
id 165
id 166
id 167
id 168
id 169
id 170
id 171
id 172
id 173
id 174
id 175
id 176
id 177
id 178
id 179
id 180
id 181
id 182
id 183
id 184
id 185
id 186
id 187
id 188
id 35
id 36
id 37
id 38
id 39
id 40
id 41
id 42
id 43
id 44
id 45
id 46
id 47
id 48
id 49
id 50
id 51
id 52
id 53
id 54
id 55
id 120
id 121
id 122
id 123
id 124
id 125
id 126
id 127

but we get

(gdb) print format.id()
$3 = 15
Comment 3 Christoph Cullmann 2018-08-20 15:40:03 UTC
Have a fix.
Comment 4 Christoph Cullmann 2018-08-20 15:52:57 UTC
Request here

https://phabricator.kde.org/D14952
Comment 5 Christoph Cullmann 2018-08-20 16:59:59 UTC
Git commit 9cfb8fa9a684917362b6a5ca99e099f5a4353ae6 by Christoph Cullmann.
Committed on 20/08/2018 at 16:59.
Pushed by cullmann into branch 'master'.

Fix includedDefinitions, handle definition change in context switch
AcceptedPublic

Fix includedDefinitions, handle definition change in context switch.
They were missing, see PHP/HTML.
I cleaned up the code a bit to just use QVector, no need for a queue, the order is anyways arbitrary (but stable).

Differential Revision: https://phabricator.kde.org/D14952

M  +10   -5    autotests/syntaxrepository_test.cpp
M  +19   -15   src/lib/definition.cpp

https://commits.kde.org/syntax-highlighting/9cfb8fa9a684917362b6a5ca99e099f5a4353ae6