Bug 437683

Summary: Using the integrated git blame on the first commit of qtbase causes a crash
Product: [Applications] kate Reporter: Noah Davis <noahadvs>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kare.sars
Priority: NOR    
Version First Reported In: Git   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Noah Davis 2021-05-25 20:47:51 UTC
SUMMARY
When I use the integrated git blame viewer to view commit 38be0d13830efd2d98281c645c3a60afe05ffece of qtbase (Initial import from the monolithic Qt), RAM usage rises rapidly up to roughly 8GB before Kate crashes.

I realize this is an absolutely massive commit and not really useful to read within Kate. I usually activate the git blame viewer on this commit by accident.

STEPS TO REPRODUCE
1. Open a file from qtbase like qwidget.h
2. Open the git blame viewer on "Initial import from the monolithic Qt"

OBSERVED RESULT
Kate's RAM usage rises to 8GB, then Kate crashes

EXPECTED RESULT
It should show the git blame info for the file without using tons of RAM or crashing.

OR

It should passively tell the user (without anything that needs to be dismissed) that the commit is too big to show.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20210522
KDE Plasma Version: 5.22.80
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.2
Kernel Version: 5.12.2-1-default (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 4800H with Radeon Graphics
Memory: 30.8 GiB of RAM
Graphics Processor: AMD RENOIR
Comment 1 Noah Davis 2021-05-25 22:55:36 UTC
Application: Kate (kate), signal: Segmentation fault
Content of s_kcrashErrorMessage: [Current thread is 1 (Thread 0x7f1d49095880 (LWP 23717))]
[KCrash Handler]
#6  0x00007f1d4c12a7db in QArrayData::data (this=<optimized out>) at ../../include/QtCore/../../src/corelib/tools/qarraydata.h:61
#7  QTypedArrayData<QTextHtmlParserNode>::data (this=<optimized out>) at ../../include/QtCore/../../src/corelib/tools/qarraydata.h:208
#8  QTypedArrayData<QTextHtmlParserNode>::begin (this=<optimized out>) at ../../include/QtCore/../../src/corelib/tools/qarraydata.h:211
#9  QVector<QTextHtmlParserNode>::realloc (this=this@entry=0x7ffeab8c6660, aalloc=6242685, options=...) at ../../include/QtCore/../../src/corelib/tools/qvector.h:719
#10 0x00007f1d4c12ad4b in QVector<QTextHtmlParserNode>::resize (this=0x7ffeab8c6660, asize=6242685) at ../../include/QtCore/../../src/corelib/tools/qvector.h:436
#11 0x00007f1d4c122855 in QTextHtmlParser::newNode (this=this@entry=0x7ffeab8c6660, parent=1) at text/qtexthtmlparser.cpp:566
#12 0x00007f1d4c1294a9 in QTextHtmlParser::parseTag (this=0x7ffeab8c6660) at text/qtexthtmlparser.cpp:684
#13 0x00007f1d4c129a98 in QTextHtmlParser::parse (this=this@entry=0x7ffeab8c6660) at text/qtexthtmlparser.cpp:640
#14 0x00007f1d4c129b42 in QTextHtmlParser::parse (this=this@entry=0x7ffeab8c6660, text=..., _resourceProvider=_resourceProvider@entry=0x55616448c920) at text/qtexthtmlparser.cpp:583
#15 0x00007f1d4c1542df in QTextHtmlImporter::QTextHtmlImporter (this=0x7ffeab8c6660, _doc=<optimized out>, _html=..., mode=<optimized out>, resourceProvider=<optimized out>) at text/qtextdocumentfragment.cpp:445
#16 0x00007f1d4c108265 in QTextDocument::setHtml (this=0x55616448c920, html=...) at text/qtextdocument.cpp:1273
#17 0x00007f1d4c96a517 in QWidgetTextControlPrivate::setContent (this=0x556163e816e0, format=format@entry=Qt::RichText, text=..., document=document@entry=0x0) at widgets/qwidgettextcontrol.cpp:506
#18 0x00007f1d4c96ad53 in QWidgetTextControl::setHtml (this=<optimized out>, text=...) at widgets/qwidgettextcontrol.cpp:1218
#19 0x00007f1d4c9487f1 in QTextEdit::setHtml (this=this@entry=0x556164471e10, text=...) at widgets/qtextedit.cpp:1232
#20 0x00007f1d44d7be14 in GitBlameTooltip::Private::showTooltip (view=..., text=..., this=0x556164471e10) at /usr/src/debug/kate-21.07.70git.20210525T100116~dd06221f6-ku.30.1.x86_64/addons/git-blame/gitblametooltip.cpp:212
#21 GitBlameTooltip::show (this=<optimized out>, text=..., view=...) at /usr/src/debug/kate-21.07.70git.20210525T100116~dd06221f6-ku.30.1.x86_64/addons/git-blame/gitblametooltip.cpp:314
#22 0x00007f1d44d7c874 in KateGitBlamePluginView::showFinished (this=0x556164489000, exitCode=<optimized out>, exitStatus=(unknown: 0xab8c68a8)) at /usr/src/debug/kate-21.07.70git.20210525T100116~dd06221f6-ku.30.1.x86_64/addons/git-blame/kategitblameplugin.cpp:343
#23 0x00007f1d4bbafc17 in QtPrivate::QSlotObjectBase::call (a=0x7ffeab8c6a40, r=0x556164489000, this=0x5561644be430) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#24 doActivate<false> (sender=0x556164489068, signal_index=11, argv=argv@entry=0x7ffeab8c6a40) at kernel/qobject.cpp:3886
#25 0x00007f1d4bba8f60 in QMetaObject::activate (sender=sender@entry=0x556164489068, m=m@entry=0x7f1d4be5c680 <QProcess::staticMetaObject>, local_signal_index=local_signal_index@entry=2, argv=argv@entry=0x7ffeab8c6a40) at kernel/qobject.cpp:3946
#26 0x00007f1d4bae5f58 in QProcess::finished (this=this@entry=0x556164489068, _t1=<optimized out>, _t2=<optimized out>) at .moc/moc_qprocess.cpp:339
#27 0x00007f1d4baeb923 in QProcessPrivate::_q_processDied (this=0x5561644412f0) at io/qprocess.cpp:1184
#28 0x00007f1d4baeba4e in QProcess::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=0x7ffeab8c6bd0) at io/qprocess.h:320
#29 0x00007f1d4bbafc50 in doActivate<false> (sender=0x556164b28980, signal_index=3, argv=argv@entry=0x7ffeab8c6bd0) at kernel/qobject.cpp:3898
#30 0x00007f1d4bba8f60 in QMetaObject::activate (sender=sender@entry=0x556164b28980, m=m@entry=0x7f1d4be5ea60 <QSocketNotifier::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7ffeab8c6bd0) at kernel/qobject.cpp:3946
#31 0x00007f1d4bbb30bf in QSocketNotifier::activated (this=this@entry=0x556164b28980, _t1=..., _t2=<optimized out>, _t3=...) at .moc/moc_qsocketnotifier.cpp:178
#32 0x00007f1d4bbb38bb in QSocketNotifier::event (this=0x556164b28980, e=0x7ffeab8c6ce0) at kernel/qsocketnotifier.cpp:302
#33 0x00007f1d4c778aff in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x556164b28980, e=0x7ffeab8c6ce0) at kernel/qapplication.cpp:3632
#34 0x00007f1d4bb7913a in QCoreApplication::notifyInternal2 (receiver=0x556164b28980, event=0x7ffeab8c6ce0) at kernel/qcoreapplication.cpp:1063
#35 0x00007f1d4bbd18f5 in socketNotifierSourceDispatch (source=source@entry=0x556163af5530) at kernel/qeventdispatcher_glib.cpp:107
#36 0x00007f1d49cd08b7 in g_main_dispatch (context=0x7f1d40005000) at ../glib/gmain.c:3337
#37 g_main_context_dispatch (context=0x7f1d40005000) at ../glib/gmain.c:4055
#38 0x00007f1d49cd0c38 in g_main_context_iterate (context=context@entry=0x7f1d40005000, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4131
#39 0x00007f1d49cd0cef in g_main_context_iteration (context=0x7f1d40005000, may_block=may_block@entry=1) at ../glib/gmain.c:4196
#40 0x00007f1d4bbd0d30 in QEventDispatcherGlib::processEvents (this=0x556163af5fd0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#41 0x00007f1d4bb77b7b in QEventLoop::exec (this=this@entry=0x7ffeab8c6ef0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#42 0x00007f1d4bb7fdb0 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#43 0x00007f1d4bfdca9c in QGuiApplication::exec () at kernel/qguiapplication.cpp:1867
#44 0x00007f1d4c778a75 in QApplication::exec () at kernel/qapplication.cpp:2824
#45 0x0000556161cbd1b0 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/kate-21.07.70git.20210525T100116~dd06221f6-ku.30.1.x86_64/kate/main.cpp:688
[Inferior 1 (process 23717) detached]
Comment 2 Kåre Särs 2021-05-27 19:13:57 UTC
What happens here (most probably) is that the diff for the commit is HUGE and we just run out of ram when we try to render the diff to html....
Comment 3 Kåre Särs 2021-05-27 19:25:44 UTC
The qtbase init commit is >180MB and almost 6 000 000 lines... The QTextBrowser  probably just can't handle it....

I think we need to add a limit for the size of the diff
Comment 4 Bug Janitor Service 2021-05-29 05:29:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/420
Comment 5 Christoph Cullmann 2021-05-29 12:31:43 UTC
Git commit ace4d9d6ebcba386990f38570699af71af3e14e3 by Christoph Cullmann, on behalf of Kåre Särs.
Committed on 29/05/2021 at 12:31.
Pushed by cullmann into branch 'master'.

Prevent crash in git-blame for HUGE git commits

M  +9    -1    addons/git-blame/kategitblameplugin.cpp

https://invent.kde.org/utilities/kate/commit/ace4d9d6ebcba386990f38570699af71af3e14e3
Comment 6 Kåre Särs 2021-05-29 13:00:36 UTC
Git commit b1b868d9fa09efcc89868cbe91d4a01d1a7aa0e5 by Kåre Särs.
Committed on 29/05/2021 at 12:59.
Pushed by sars into branch 'release/21.04'.

Prevent crash in git-blame for HUGE git commits

M  +9    -1    addons/git-blame/kategitblameplugin.cpp

https://invent.kde.org/utilities/kate/commit/b1b868d9fa09efcc89868cbe91d4a01d1a7aa0e5