Fixed Bug Which Caused Infinite Loop While Highlighting Kconfig Files
ClosedPublic

Authored by jwilbee on Jan 25 2019, 1:24 AM.

Details

Summary

Fixed bug where typing menu or menuconfig while editng a kconfig file would cause the loop at abstracthighlighter.cpp:299 to get stuck in an infite loop. This would occur because the config_entry_start and menu_entry contexts would push an error line end context and the error line end context would pop back to the config_entry or menu_entry contexts.

There should probably also be a loop counter or something in that loop to keep
the end application from dying due to a bad definition.

Test Plan

Open up a kconfig file in a text editor and attempt to type "menu", "config", or "menuconfig"

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
jwilbee created this revision.Jan 25 2019, 1:24 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptJan 25 2019, 1:24 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
jwilbee requested review of this revision.Jan 25 2019, 1:24 AM
shubham added a subscriber: shubham.EditedJan 25 2019, 2:55 AM

Thanks jwilbee for the patch, but please don't make the title , a summary, keep it short to the point.

jwilbee retitled this revision from Fixed bug where typing menu or menuconfig while editng a kconfig file would cause the loop at abstracthighlighter.cpp:299 to get stuck in an inite loop. This would occur because the config_entry_start and menu_entry contexts would push an error... to Fixed Bug Which Caused Infinite Loop While Highlighting Kconfig Files.Jan 25 2019, 5:25 AM
jwilbee edited the summary of this revision. (Show Details)
nibags added a subscriber: nibags.Jan 25 2019, 7:45 AM

The bug is identical to D17891 !
Please, also put #pop!error in fallthroughContext="error", on lines 238 and 363.
And increase the file version

I thought I had a endless loop/recursion detection, bad :/
Will take a look.

jwilbee updated this revision to Diff 50286.Jan 25 2019, 8:07 PM

Added requested changes to fallthrough context
Incremented version number

Can you add a unit tedt for this? I.e. an example file in autotest/input?

Otherwise: could you paste some example test that hits this bug?

I can reproduce it, I will add a test ;=)

Git commit 320e1bccbb68dc21d43be0d0c7067866b96fd7be by Christoph Cullmann.
Committed on 26/01/2019 at 15:27.
Pushed by cullmann into branch 'master'.

check for endless context switches

avoid infinite loops for broken hl definitions

same trick as for endless looping during normal hl, don't allow more than 1024 changes

M +34 -3 src/lib/abstracthighlighter.cpp

https://commits.kde.org/syntax-highlighting/320e1bccbb68dc21d43be0d0c7067866b96fd7be

cullmann accepted this revision.Jan 26 2019, 3:33 PM

I added a test and will push this fix now.

This revision is now accepted and ready to land.Jan 26 2019, 3:33 PM
This revision was automatically updated to reflect the committed changes.

Together with my other commit, this should now be fixed for good.
Even if again some definition is bad, at least not endless looping will occur.
Thanks for the bug finding & fixing!