Bug 460578 - kate stuck when opening huge single line file
Summary: kate stuck when opening huge single line file
Status: RESOLVED INTENTIONAL
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 22.08.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-17 09:59 UTC by Germano Massullo
Modified: 2022-12-14 00:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
gdb trace (35.30 KB, text/plain)
2022-10-17 09:59 UTC, Germano Massullo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Germano Massullo 2022-10-17 09:59:35 UTC
Created attachment 152926 [details]
gdb trace

This bugreport concerns kate-22.08.1
Website https://profiler.firefox.com/ generates a big single line JSON file. In my case the dimension is ~40 MB.
Kate is not able to open it, and it will get stuck. I noticed that it can happen also with smaller files (8 MB).
I managed to get some parts of GDB debugging. some may get lost since GDB has tried to print content of the huge file in standard output, exceeding Yakuake unlimited scroll limit. By running GDB again I should have been to reconstruct the GDB output

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 36
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Comment 1 Jonathan Poelen 2022-11-10 00:40:47 UTC
Developer's note: This is related to the way QRegularExpression works in Qt5: the text is copied for each call to match(QStringView) in syntax-highlighting: https://codebrowser.dev/qt5/qtbase/src/corelib/text/qregularexpression.h.html#_ZNK18QRegularExpression5matchE11QStringViewiNS_9MatchTypeE6QFlagsINS_11MatchOptionEE

Qt6 does not have this defect. With kate-syntax-highlighter --output-format=ansi256colors and a json of 1.9M, it takes 45s with Qt5, but less than 1 second with Qt6.
Comment 2 Jonathan Poelen 2022-11-10 22:02:36 UTC
QString::fromRawData()'s document explains how to avoid copies with QRegularExpression, but there is a bug in Qt5 which will not be fixed: https://bugreports.qt.io/browse/QTBUG-108302