Version: 4 (using 4.2.00 (KDE 4.2.0), Kubuntu packages) Compiler: cc OS: Linux (i686) release 2.6.26-5-generic Reproduction steps: -use the attached worksheet (import worksheet) -right-click the top left pane (CPU 1) and select "Properties" -in the "Settings" window select the "Sensors" tab and press the -"Delete" button to remove the first sensor -press "OK" or "Apply" Now when you exit the application it will crash with the following backtrace: Application: System Monitor (ksysguard), signal SIGSEGV [Current thread is 0 (LWP 1410)] Thread 2 (Thread 0xb34d6b90 (LWP 1411)): #0 0xb800f424 in __kernel_vsyscall () #1 0xb66287b1 in select () from /lib/tls/i686/cmov/libc.so.6 #2 0xb71fc300 in ?? () from /usr/lib/libQtCore.so.4 #3 0xb712c74e in ?? () from /usr/lib/libQtCore.so.4 #4 0xb58734ff in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 #5 0xb663049e in clone () from /lib/tls/i686/cmov/libc.so.6 Thread 1 (Thread 0xb4b64720 (LWP 1410)): [KCrash Handler] #6 KSignalPlotter::beamColor (this=0x99f7d38, index=3) at /usr/include/qt4/QtGui/qcolor.h:255 #7 0xb7f9fc7c in FancyPlotter::saveSettings (this=0x9a12c88, doc=@0xbfe29a14, element=@0xbfe299ac) at /build/buildd/kdebase-workspace-4.2.0/ksysguard/gui/SensorDisplayLib/FancyPlotter.cc:634 #8 0xb7fd2c3a in WorkSheet::exportWorkSheet (this=0x9a0b928, fileName=@0xbfe29a5c) at /build/buildd/kdebase-workspace-4.2.0/ksysguard/gui/WorkSheet.cc:229 #9 0xb7fdae7b in Workspace::saveWorkSheet (this=0x966b030, sheet=0x9a0b928) at /build/buildd/kdebase-workspace-4.2.0/ksysguard/gui/Workspace.cc:212 #10 0xb7fdb467 in Workspace::saveOnQuit (this=0x966b030) at /build/buildd/kdebase-workspace-4.2.0/ksysguard/gui/Workspace.cc:170 #11 0xb7fdf798 in TopLevel::queryClose (this=0x9669be0) at /build/buildd/kdebase-workspace-4.2.0/ksysguard/gui/ksysguard.cc:374 #12 0xb78833d0 in KMainWindow::closeEvent (this=0x9669be0, e=0xbfe2a104) at /build/buildd/kde4libs-4.2.0/kdeui/widgets/kmainwindow.cpp:587 #13 0xb6965343 in QWidget::event () from /usr/lib/libQtGui.so.4 #14 0xb6cb95c7 in QMainWindow::event () from /usr/lib/libQtGui.so.4 #15 0xb7882b17 in KMainWindow::event (this=0x9669be0, ev=0xbfe2a104) at /build/buildd/kde4libs-4.2.0/kdeui/widgets/kmainwindow.cpp:1093 #16 0xb78c737c in KXmlGuiWindow::event (this=0x9669be0, ev=0xbfe2a104) at /build/buildd/kde4libs-4.2.0/kdeui/xmlgui/kxmlguiwindow.cpp:131 #17 0xb7fe2b31 in TopLevel::event (this=0x9669be0, e=0x30000f2) at /build/buildd/kdebase-workspace-4.2.0/ksysguard/gui/ksysguard.cc:335 #18 0xb690d84c in QApplicationPrivate::notify_helper () from /usr/lib/libQtGui.so.4 #19 0xb691579a in QApplication::notify () from /usr/lib/libQtGui.so.4 #20 0xb77a007d in KApplication::notify (this=0x95e4ac0, receiver=0x9669be0, event=0xbfe2a104) at /build/buildd/kde4libs-4.2.0/kdeui/kernel/kapplication.cpp:307 #21 0xb721cff1 in QCoreApplication::notifyInternal () from /usr/lib/libQtCore.so.4 #22 0xb6968473 in QWidgetPrivate::close_helper () from /usr/lib/libQtGui.so.4 #23 0xb696d5cb in QApplication::x11ClientMessage () from /usr/lib/libQtGui.so.4 #24 0xb697e6dc in QApplication::x11ProcessEvent () from /usr/lib/libQtGui.so.4 #25 0xb69a879a in ?? () from /usr/lib/libQtGui.so.4 #26 0xb57a3af8 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0 #27 0xb57a705b in ?? () from /usr/lib/libglib-2.0.so.0 #28 0xb57a71d8 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0 #29 0xb7247628 in QEventDispatcherGlib::processEvents () from /usr/lib/libQtCore.so.4 #30 0xb69a7e95 in ?? () from /usr/lib/libQtGui.so.4 #31 0xb721b6ba in QEventLoop::processEvents () from /usr/lib/libQtCore.so.4 #32 0xb721b87a in QEventLoop::exec () from /usr/lib/libQtCore.so.4 #33 0xb721df35 in QCoreApplication::exec () from /usr/lib/libQtCore.so.4 #34 0xb690d6c7 in QApplication::exec () from /usr/lib/libQtGui.so.4 #35 0xb7fe1ce4 in kdemain (argc=1, argv=0xbfe2aa94) at /build/buildd/kdebase-workspace-4.2.0/ksysguard/gui/ksysguard.cc:590 #36 0x080486b2 in main (argc=1, argv=0xffff) at /build/buildd/kdebase-workspace-4.2.0/obj-i486-linux-gnu/ksysguard/gui/ksysguard_dummy.cpp:3
Created attachment 31503 [details] Worksheet that produces crash on exit after editing
I just analyzed this: When removing a beam from the plotter which is not the last... the indexes are not updated to match the mBeamColors list index. So , in this case, removing the first beam will do this: The sensors indexes will be 1,2,3 (0 was removed) mBeamColors indexes will be 0,1,2 (as removing a item in a list doesn't preserve the index/position) When accessing the sensor index "3" , mBeamColors.at(3) will crash as it is a non existant index Possible solutions: - Update the sensors indexes on removing a beam - Use "replace" instead of "remove" on mBeamColors to preserve the indexes position - Use a QMap<index,QColor> instead a QList<QColor>
Or, using the mBeams indexes on save (instead of the sensors indexes) But it seems there is a strange relationship I can't tell by just looking at the code without knowing it
Created attachment 33982 [details] Proposed patch This will modify the sensors() beamId to match the m_beamColors/Data indexes. I don't know if this will cause side effects, I just tested it and it works, it doesn't seem to affect other parts of the application and it doesn't crash anymore.
Fix and patch for code rewrite provided here https://bugs.kde.org/show_bug.cgi?id=179305
*** This bug has been marked as a duplicate of bug 179305 ***