Bug 368751 - KCachegrind crashes after a profile gets loaded
Summary: KCachegrind crashes after a profile gets loaded
Status: RESOLVED FIXED
Alias: None
Product: kcachegrind
Classification: Developer tools
Component: general (show other bugs)
Version: 0.7.4kde
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Josef Weidendorfer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-13 14:48 UTC by Jānis Elmeris
Modified: 2016-10-21 17:45 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Proposed patch (374 bytes, patch)
2016-09-29 15:58 UTC, Josef Weidendorfer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jānis Elmeris 2016-09-13 14:48:25 UTC
Application: kcachegrind (0.7.4kde)
KDE Platform Version: 4.13.3
Qt Version: 4.8.6
Operating System: Linux 3.13.0-24-generic x86_64
Distribution: Linux Mint 17 Qiana

-- Information about the crash:
- What I was doing when the application crashed:

Opened profile data either by using the "Open" command explicitly or by opening the profile data file using "Open Witch KCachegrind".

The loading progress bar reaches the end and the application crashes.

It crashes when I try it with some profile files, does not crash with other profile files.

The crash can be reproduced every time.

-- Backtrace:
Application: KCachegrind (kcachegrind), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[KCrash Handler]
#6  FixFile::nextLine (this=this@entry=0x7fff3ef81110, str=...) at ../../libcore/utils.cpp:439
#7  0x0000000000449480 in CachegrindLoader::loadInternal (this=this@entry=0x7fff3ef81190, data=data@entry=0x19bd870, device=device@entry=0x7fff3ef813d0, filename=...) at ../../libcore/cachegrindloader.cpp:754
#8  0x000000000044aabe in CachegrindLoader::load (this=0x17c4370, d=0x19bd870, file=0x7fff3ef813d0, filename=...) at ../../libcore/cachegrindloader.cpp:182
#9  0x00000000004398f1 in TraceData::internalLoad (this=this@entry=0x19bd870, device=device@entry=0x7fff3ef813d0, filename=...) at ../../libcore/tracedata.cpp:3206
#10 0x0000000000443459 in TraceData::load (this=this@entry=0x19bd870, files=...) at ../../libcore/tracedata.cpp:3160
#11 0x000000000044390d in TraceData::load (this=this@entry=0x19bd870, file=...) at ../../libcore/tracedata.cpp:3173
#12 0x0000000000428bc4 in TopLevel::openDataFile (this=this@entry=0x17c4c40, file=...) at ../../kcachegrind/toplevel.cpp:2375
#13 0x0000000000428d3b in TopLevel::load (this=this@entry=0x17c4c40, file=...) at ../../kcachegrind/toplevel.cpp:970
#14 0x0000000000429583 in load (file=..., this=0x17c4c40) at ../../kcachegrind/toplevel.cpp:1048
#15 TopLevel::loadTraceDelayed (this=0x17c4c40) at ../../kcachegrind/toplevel.cpp:1046
#16 0x000000000042a4b5 in TopLevel::qt_static_metacall (_o=0x17c4c40, _id=1056444656, _a=0x0, _c=<optimized out>) at ./toplevel.moc:300
#17 0x00007f031e505c1e in QObject::event (this=this@entry=0x17c4c40, e=e@entry=0x19bd1a0) at kernel/qobject.cpp:1194
#18 0x00007f031f1b156b in QWidget::event (this=this@entry=0x17c4c40, event=event@entry=0x19bd1a0) at kernel/qwidget.cpp:8846
#19 0x00007f031f56ba33 in QMainWindow::event (this=this@entry=0x17c4c40, event=event@entry=0x19bd1a0) at widgets/qmainwindow.cpp:1478
#20 0x00007f031ff257a1 in KMainWindow::event (this=this@entry=0x17c4c40, ev=ev@entry=0x19bd1a0) at ../../kdeui/widgets/kmainwindow.cpp:1084
#21 0x00007f031ff5d119 in KXmlGuiWindow::event (this=0x17c4c40, ev=0x19bd1a0) at ../../kdeui/xmlgui/kxmlguiwindow.cpp:126
#22 0x00007f031f161e2c in QApplicationPrivate::notify_helper (this=this@entry=0x1520700, receiver=receiver@entry=0x17c4c40, e=e@entry=0x19bd1a0) at kernel/qapplication.cpp:4567
#23 0x00007f031f1684a0 in QApplication::notify (this=this@entry=0x7fff3ef81e20, receiver=receiver@entry=0x17c4c40, e=e@entry=0x19bd1a0) at kernel/qapplication.cpp:4353
#24 0x00007f031fe7163a in KApplication::notify (this=0x7fff3ef81e20, receiver=0x17c4c40, event=0x19bd1a0) at ../../kdeui/kernel/kapplication.cpp:311
#25 0x00007f031e4ed4dd in QCoreApplication::notifyInternal (this=0x7fff3ef81e20, receiver=receiver@entry=0x17c4c40, event=event@entry=0x19bd1a0) at kernel/qcoreapplication.cpp:953
#26 0x00007f031e4f0b3d in sendEvent (event=0x19bd1a0, receiver=0x17c4c40) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#27 QCoreApplicationPrivate::sendPostedEvents (receiver=receiver@entry=0x0, event_type=event_type@entry=0, data=0x14f9020) at kernel/qcoreapplication.cpp:1577
#28 0x00007f031e4f0fe3 in QCoreApplication::sendPostedEvents (receiver=receiver@entry=0x0, event_type=event_type@entry=0) at kernel/qcoreapplication.cpp:1470
#29 0x00007f031e51af83 in sendPostedEvents () at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:236
#30 postEventSourceDispatch (s=0x1521750) at kernel/qeventdispatcher_glib.cpp:287
#31 0x00007f031ab80e04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#32 0x00007f031ab81048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#33 0x00007f031ab810ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#34 0x00007f031e51a7a1 in QEventDispatcherGlib::processEvents (this=0x14fa9a0, flags=...) at kernel/qeventdispatcher_glib.cpp:434
#35 0x00007f031f203be6 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#36 0x00007f031e4ec0af in QEventLoop::processEvents (this=this@entry=0x7fff3ef81d20, flags=...) at kernel/qeventloop.cpp:149
#37 0x00007f031e4ec3a5 in QEventLoop::exec (this=this@entry=0x7fff3ef81d20, flags=...) at kernel/qeventloop.cpp:204
#38 0x00007f031e4f1b79 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1225
#39 0x00007f031f16037c in QApplication::exec () at kernel/qapplication.cpp:3828
#40 0x000000000041d6c4 in main (argc=4, argv=0x7fff3ef81f58) at ../../kcachegrind/main.cpp:91

Report to https://bugs.kde.org/

Reproducible: Always

Steps to Reproduce:
1. Right-click on a profile data.
2. Select "Open Witch KCachegrind".
3. Wait while the data is being loaded and the app crashes at the end.

Actual Results:  
Crashes. The KDE Crash Handler appears.

Expected Results:  
Does not crash.
Comment 1 Josef Weidendorfer 2016-09-13 15:12:44 UTC
Thanks.

I assume this is an out-of-memory error (duplicate of Bug 232470).
How large is the file you load? Which tool created the file?
Comment 2 Jānis Elmeris 2016-09-13 17:22:14 UTC
It's about 180 MB. Created by XDebug. 140 MB files opened all right.
Comment 3 Jānis Elmeris 2016-09-13 17:30:21 UTC
> Regarding "top": run it in a terminal nearby and observe the memory usage while KCachegrind is loading this huge file. What is the maximum number e.g. for resident size directly before KCachegrind crashes?
%MEM goes up to 4,8%.
RES goes up to about 348712.
Comment 4 Josef Weidendorfer 2016-09-13 20:51:38 UTC
Hmm... probably not out-of-memory then.

Any chance for me to reproduce the bug, ie. can you make
the file available to me (e.g. via sending me a link in private
email)?
Comment 5 Josef Weidendorfer 2016-09-29 15:58:54 UTC
Created attachment 101346 [details]
Proposed patch

After private conversation, the bug should be fixed with the proposed patch.
The code accesses one byte after the memory-mapped input file.
valgrind did not detect it, as it does not catch accesses beyound mapping of files (?).
Comment 6 Luigi Toscano 2016-10-21 14:55:01 UTC
The fix was pushed in revision 4e5f940b57ae1089db29e0700d30cc309cf27805, so it will be included in Applications/16.12 (maybe it could have been applied to 16.08 too?). Could this bug be closed?
Comment 7 Josef Weidendorfer 2016-10-21 17:45:30 UTC
I wanted to wait for a confirmation from the bug reporter as I could not reproduce the bug.

With more effort, I just could force the original bug to appear, and I can confirm now that the fix
actually works.

So, closing.
Backported to 16.08 in dff74b.