Bug 135783 - circular IncludeRules causes infinite loop in handleKateHlIncludeRulesRecursive
Summary: circular IncludeRules causes infinite loop in handleKateHlIncludeRulesRecursive
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: syntax (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords: investigated, triaged
Depends on:
Blocks:
 
Reported: 2006-10-17 02:37 UTC by Matthew Woehlke
Modified: 2018-09-23 17:25 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Woehlke 2006-10-17 02:37:09 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Compiled From Sources
Compiler:          gcc (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1) 
OS:                Linux

I have an xml that looks roughly like this (pseudocode):

<context normal>
   <Include DetectComments##Roff>
   <DetectChar '.' column=0 context=DetectDirectives>
   <Include DetectOthers##Roff>
</context>
<context DetectDirectives>
   <Keyword MyDirectives>
   <Include DetectDirectives##Roff>
</context>

The expected behavior is to include the 'DetectOthers' context in the .xml for the 'Roff' highlighter.

Actual behavior is the following infinite recursion leading to SEGV due to stack overflow:

#0  0x08f8aa87 in KateHighlighting::handleKateHlIncludeRulesRecursive (this=0x98cca98, it={node = 0x9983110}, list=0x98ccb30) at katehighlight.cpp:2544
#1  0x08f8ac38 in KateHighlighting::handleKateHlIncludeRulesRecursive (this=0x98cca98, it={node = 0x997a9a0}, list=0x98ccb30) at katehighlight.cpp:2576
... (repeats 56664 times)
#56666 0x08f8ac38 in KateHighlighting::handleKateHlIncludeRulesRecursive (this=0x98cca98, it={node = 0x997a9a0}, list=0x98ccb30) at katehighlight.cpp:2576
#56667 0x08f8ac38 in KateHighlighting::handleKateHlIncludeRulesRecursive (this=0x98cca98, it={node = 0x997a9a0}, list=0x98ccb30) at katehighlight.cpp:2576
#56668 0x08f8aa60 in KateHighlighting::handleKateHlIncludeRules (this=0x98cca98) at katehighlight.cpp:2540
#56669 0x08f8a62b in KateHighlighting::makeContextList (this=0x98cca98) at katehighlight.cpp:2473
#56670 0x08f85681 in KateHighlighting::init (this=0x98cca98) at katehighlight.cpp:1787
#56671 0x08f855a7 in KateHighlighting::use (this=0x98cca98) at katehighlight.cpp:1757
#56672 0x08f3c018 in KateBuffer::setHighlight (this=0x96c5008, hlMode=46) at katebuffer.cpp:871
#56673 0x08f66caf in KateDocument::setHlMode (this=0x96ed538, mode=46) at katedocument.cpp:1775
#56674 0x08f901b6 in KateViewHighlightAction::setHl (this=0x97bf500, mode=46) at katehighlight.cpp:3447
#56675 0x08f7ed43 in KateViewHighlightAction::qt_invoke (this=0x97bf500, _id=19, _o=0xbff3dd50) at katehighlight.moc:176
(omit the qt calls)

If the above is not sufficient to reproduce, I can attach actual .xml's. I also intend to look into this myself.
Comment 1 Matthew Woehlke 2006-10-17 21:59:14 UTC
Ok, it looks like the problem is that 'foo##bar' is not being correctly resolved (instead it is being resolved to context 0, which is the context IncludeRules is being called from). That being the case, maybe it's time to do something about:

"  //TODO: catch circular references: eg 0->1->2->3->1"

...or in this case, the even-more-trivial 0->0
Comment 2 Matthew Woehlke 2006-10-17 23:19:36 UTC
Creating enhancement request (bug #135844) with patch attached. This fixes the reported instance of this crash, but not the underlying cause (i.e. failure to handle circular references), so I'm leaving this open as well.

Someone with write access might want to update the description to 'circular IncludeRules crashes kate' or similar.
Comment 3 Matthew Woehlke 2007-03-23 19:51:44 UTC
...someone is now me :-)
Comment 4 Matthew Woehlke 2007-03-29 17:43:46 UTC
Note that the patch for bug 135844 resolves this particular example (but not the general problem).
Comment 5 Anders Lund 2007-03-29 18:58:17 UTC
On Thursday 29 March 2007, Matthew Woehlke wrote:
> Note that the patch for bug 135844 resolves this particular example (but
> not the general problem).


IMHO, this is a regression, the code (written by jowenn) did take this problem 
in consideration.
Comment 6 Christoph Feck 2011-12-20 02:58:13 UTC
This crash report is at least 4 years old and there were no further comments or status updates since then.

Therefore we believe that this crash is already fixed in KDE 4 or the backtrace is no longer applicable to KDE 4.

If the crash still happens with a recent KDE version (4.7.4 or 4.8), please add an updated backtrace or provide steps to reproduce. For more information, see http://techbase.kde.org/Development/Tutorials/Debugging/How_to_create_useful_crash_reports

(To prevent automatic closing of this bug in the future, please set the bug status to ASSIGNED or NEW)
Comment 7 Andrew Crouthamel 2018-09-22 02:01:20 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days, the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information.

For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please set the bug status as REPORTED so that the KDE team knows that the bug is ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 8 Dominik Haumann 2018-09-23 17:25:43 UTC
The syntax highlighting implementation now switched to the rewritten framework KSyntaxHighlighting: Please test again, since the old code is gone :)