AppArmor: fix crashes in open rules (in KF5.50) and improvements for the new Solarized schemes

Authored by nibags on Sep 26 2018, 2:45 PM.



After upgrading to KDE Frameworks 5.50.0, Kate crashes when detecting open AppArmor rules (the AppArmor rules are closed with a comma. If the user doesn't write a comma, the syntax highlighting underlines the statement of the following rule. This is defined in the _end_rule_irnc context of the XML file.)

The problem occurs with the use of #pop#pop!context in the _end_rule_irnc context, only in KF5.50. However, apparently, this only happens in very large files. For example, this problem occurs to me when I open the new test file, updated in this diff. However, I do not know the exact cause of this error...

On line 184 of the test file, I put some examples of open AppArmor rules.

Also, some changes are made in the colors so that the highlighting looks better in the last update of Solarized schemes.

Diff Detail

R216 Syntax Highlighting
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
nibags created this revision.Sep 26 2018, 2:45 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptSep 26 2018, 2:45 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Sep 26 2018, 2:45 PM

Have you some backtrace from the crash?

I did debug with gdb and valgrind, but the information is not relevant, since Kate freezes and I have to kill the process (I think I used the term "crash" incorrectly :S).
I have done some tests and the problem is in the use of #pop!some_context on the main context ("_profile").
For example, formerly, when doing #pop!some_context on the main context, "some_context" was stacked on top of the main context, it did not replace it. Now, in KF5.50.0, the main context is removed from de "stack" and replaced by "some_context". In the AppArmor XML file I use #pop#pop!some_context in general to finish a rule and, in some cases, #pop!some_context is done in the main context, which produces the error in large files, since it is not a behavior that I envisioned.

I do not know if I'm explaining myself well, but with this diff I solve the problem.

cullmann accepted this revision.Sep 27 2018, 5:28 PM

I would say: this should go in to workaround the current issue.

If you have a file, that triggers the "freeze" with the old version, I would be happy to get it here as attachment afterwards to take a look at the issue.
It might occur in other places, too.


This revision is now accepted and ready to land.Sep 27 2018, 5:28 PM

I attach two files. The "usr.bin.firefox" file causes the error on line 31 and "usr.bin.apparmor-profile-test" on line 184.

This revision was automatically updated to reflect the committed changes.

Thanks for the examples, with that I could reproduce and introduce some hard guard for such cases.
Better broken highlighting then an endless hanging application.