dont crash when cancelling process
ClosedPublic

Authored by brauch on Jan 13 2018, 3:41 PM.

Details

Summary

See: https://forum.kde.org/viewtopic.php?f=218&t=129389

Not sure if this is the right fix, I didn't really look into it in depth ... maybe the process should not be deleted that early ... Aleix?

This is the valgrind output, process is already deleted when the debug is called:

==11028== Invalid read of size 8
==11028==    at 0xA79EAF4: KProcess::program() const (in /usr/lib/libKF5CoreAddons.so.5.41.0)
==11028==    by 0x4F80A0D: operator() (runtimecontroller.cpp:44)
==11028==    by 0x4F80A0D: call (qobjectdefs_impl.h:130)
==11028==    by 0x4F80A0D: call<QtPrivate::List<QProcess::ProcessError>, void> (qobjectdefs_impl.h:240)
==11028==    by 0x4F80A0D: QtPrivate::QFunctorSlotObject<IdentityRuntime::startProcess(KProcess*) const::{lambda(QProcess::ProcessError)#1}, 1, QtPrivate::List<QProcess::ProcessError>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (qobjectdefs_impl.h:423)
==11028==    by 0xBCE5B2E: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBC2E551: QProcess::errorOccurred(QProcess::ProcessError) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBC35590: ??? (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBC3A834: ??? (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBC2FD6B: QProcess::waitForFinished(int) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBC306F1: QProcess::~QProcess() (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xA79E809: KProcess::~KProcess() (in /usr/lib/libKF5CoreAddons.so.5.41.0)
==11028==    by 0xBCE354C: QObjectPrivate::deleteChildren() (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBCED17B: QObject::~QObject() (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0x545C31C2: ~ScriptAppJob (scriptappjob.h:38)
==11028==    by 0x545C31C2: ScriptAppJob::~ScriptAppJob() (scriptappjob.h:38)
==11028==    by 0xBCE6470: QObject::event(QEvent*) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xAB53E3B: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xAB5B815: QApplication::notify(QObject*, QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xBCB51DF: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBCB7E45: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBD120A3: ??? (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0x1554C26F: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.5400.0)
==11028==    by 0x1554DF68: ??? (in /usr/lib/libglib-2.0.so.0.5400.0)
==11028==    by 0x1554DFAD: g_main_context_iteration (in /usr/lib/libglib-2.0.so.0.5400.0)
==11028==    by 0xBD11690: QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0x31152151: ??? (in /usr/lib/libQt5XcbQpa.so.5.10.0)
==11028==    by 0xBCB382A: QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBCBCB17: QCoreApplication::exec() (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0x114B9A: main (main.cpp:824)
==11028==  Address 0x677edbf0 is 0 bytes inside a block of size 32 free'd
==11028==    at 0x4C2E64B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11028==    by 0xA79E7ED: KProcess::~KProcess() (in /usr/lib/libKF5CoreAddons.so.5.41.0)
==11028==    by 0xA79E809: KProcess::~KProcess() (in /usr/lib/libKF5CoreAddons.so.5.41.0)
==11028==    by 0xBCE354C: QObjectPrivate::deleteChildren() (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBCED17B: QObject::~QObject() (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0x545C31C2: ~ScriptAppJob (scriptappjob.h:38)
==11028==    by 0x545C31C2: ScriptAppJob::~ScriptAppJob() (scriptappjob.h:38)
==11028==    by 0xBCE6470: QObject::event(QEvent*) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xAB53E3B: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xAB5B815: QApplication::notify(QObject*, QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xBCB51DF: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBCB7E45: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBD120A3: ??? (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0x1554C26F: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.5400.0)
==11028==    by 0x1554DF68: ??? (in /usr/lib/libglib-2.0.so.0.5400.0)
==11028==    by 0x1554DFAD: g_main_context_iteration (in /usr/lib/libglib-2.0.so.0.5400.0)
==11028==    by 0xBD11690: QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0x31152151: ??? (in /usr/lib/libQt5XcbQpa.so.5.10.0)
==11028==    by 0xBCB382A: QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBCBCB17: QCoreApplication::exec() (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0x114B9A: main (main.cpp:824)
==11028==  Block was alloc'd at
==11028==    at 0x4C2D52F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11028==    by 0xA79E467: KProcess::KProcess(QObject*) (in /usr/lib/libKF5CoreAddons.so.5.41.0)
==11028==    by 0x545C065B: ScriptAppJob::ScriptAppJob(ExecuteScriptPlugin*, KDevelop::ILaunchConfiguration*) (scriptappjob.cpp:51)
==11028==    by 0x545B9D66: ScriptAppLauncher::start(QString const&, KDevelop::ILaunchConfiguration*) (scriptappconfig.cpp:166)
==11028==    by 0x4F2942F: KDevelop::RunController::execute(QString const&, KDevelop::ILaunchConfiguration*) (runcontroller.cpp:425)
==11028==    by 0x4F2AA78: KDevelop::RunController::executeDefaultLaunch(QString const&) (runcontroller.cpp:878)
==11028==    by 0x4F28B18: KDevelop::RunController::slotExecute() (runcontroller.cpp:561)
==11028==    by 0xBCE5B2E: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xAB4D382: QAction::triggered(bool) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xAB4FC05: QAction::activate(QAction::ActionEvent) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xACD5C34: ??? (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xACDD2FB: ??? (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xACDE163: QMenu::mouseReleaseEvent(QMouseEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xAB93E37: QWidget::event(QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xACE049B: QMenu::event(QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xAB53E3B: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xAB5BD90: QApplication::notify(QObject*, QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xBCB51DF: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xAB5AD19: QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xABAEFB6: ??? (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xABB199F: ??? (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xAB53E3B: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xAB5B815: QApplication::notify(QObject*, QEvent*) (in /usr/lib/libQt5Widgets.so.5.10.0)
==11028==    by 0xBCB51DF: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xB361633: QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) (in /usr/lib/libQt5Gui.so.5.10.0)
==11028==    by 0xB363185: QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) (in /usr/lib/libQt5Gui.so.5.10.0)
==11028==    by 0xB33ABBB: QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (in /usr/lib/libQt5Gui.so.5.10.0)
==11028==    by 0x3115215C: ??? (in /usr/lib/libQt5XcbQpa.so.5.10.0)
==11028==    by 0xBCB382A: QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (in /usr/lib/libQt5Core.so.5.10.0)
==11028==    by 0xBCBCB17: QCoreApplication::exec() (in /usr/lib/libQt5Core.so.5.10.0)
==11028==

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
brauch created this revision.Jan 13 2018, 3:41 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJan 13 2018, 3:41 PM
brauch requested review of this revision.Jan 13 2018, 3:41 PM
brauch edited the summary of this revision. (Show Details)
apol accepted this revision.Jan 13 2018, 9:54 PM

Note process doesn't need to be captured there. Possibly a nicer fix would be to call waitForFinished on our side, but for now this is fine.

This revision is now accepted and ready to land.Jan 13 2018, 9:54 PM
This revision was automatically updated to reflect the committed changes.