Bug 479596 - Dolphin crashes after terminal is closed with "exit" and Dolphin is then closed
Summary: Dolphin crashes after terminal is closed with "exit" and Dolphin is then closed
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: panels: terminal (show other bugs)
Version: 24.01.85
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2024-01-10 08:57 UTC by Akseli Lahtinen
Modified: 2024-01-10 09:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Akseli Lahtinen 2024-01-10 08:57:08 UTC
SUMMARY

If Dolphin terminal is open, and one types exit there and then closes Dolphin, Dolphin crashes due to a dangling pointer.


STEPS TO REPRODUCE
1. Open Dolphin and it's terminal panel
2. Type exit in terminal panel
3. Close Dolphin

OBSERVED RESULT
Dolphin crashes 

EXPECTED RESULT
Dolphin closes without crashing

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 39
KDE Plasma Version: 5.91.90
KDE Frameworks Version: 5.248.0
Qt Version: 6.6.0
Kernel Version: 6.6.9-200.fc39.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 3600 6-Core Processor
Memory: 15.5 GiB of RAM
Graphics Processor: AMD Radeon RX 6600

BACKTRACE:

#0  QObjectPrivate::ConnectionData::signalVectorCount (this=0x121b470)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qobject_p_p.h:219
#1  0x00007ffff37f9b68 in QMetaObjectPrivate::disconnect
    (sender=0x112f9f0, signal_index=0, smeta=0x5d5120 <QObject::staticMetaObject@Qt_6>, receiver=0xb20ee0, method_index=-1, slot=0x7fffffffb8e0, disconnectType=QMetaObjectPrivate::DisconnectAll)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qobject.cpp:3649
#2  0x00007ffff37f9e29 in QObject::disconnectImpl
    (sender=0x112f9f0, signal=<optimized out>, receiver=0xb20ee0, slot=0x7fffffffb8e0, senderMetaObject=0x5d5120 <QObject::staticMetaObject@Qt_6>)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qobject.cpp:5277
#3  0x00000000004b98a2 in QObject::disconnect<void (QObject::*)(QObject*), void (TerminalPanel::*)()>
    (sender=0x112f9f0, signal=(void (QObject::*)(QObject * const, QObject *)) 0x438490 <QObject::destroyed(QObject*)@plt>, receiver=0xb20ee0, slot=(void (TerminalPanel::*)(TerminalPanel * const)) 0x4b663a <TerminalPanel::terminalExited()>) at /usr/include/qt6/QtCore/qobject.h:276
#4  0x00000000004b64fd in TerminalPanel::~TerminalPanel (this=0xb20ee0, __in_chrg=<optimized out>)
    at /home/akseli/Repositories/kde/src/dolphin/src/panels/terminal/terminalpanel.cpp:53
#5  0x00000000004b6566 in TerminalPanel::~TerminalPanel (this=0xb20ee0, __in_chrg=<optimized out>)
    at /home/akseli/Repositories/kde/src/dolphin/src/panels/terminal/terminalpanel.cpp:55
#6  0x00007ffff37fa71d in QObjectPrivate::deleteChildren (this=this@entry=0xaae930)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qobject.cpp:2206
#7  0x00007ffff4a19b18 in QWidget::~QWidget (this=0xa76040, __in_chrg=<optimized out>)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/widgets/kernel/qwidget.cpp:1537
#8  0x0000000000521061 in DolphinDockWidget::~DolphinDockWidget (this=0xa76040, __in_chrg=<optimized out>)
    at /home/akseli/Repositories/kde/src/dolphin/src/dolphindockwidget.cpp:55
#9  0x0000000000521082 in DolphinDockWidget::~DolphinDockWidget (this=0xa76040, __in_chrg=<optimized out>)
    at /home/akseli/Repositories/kde/src/dolphin/src/dolphindockwidget.cpp:55
#10 0x00007ffff37fa71d in QObjectPrivate::deleteChildren (this=this@entry=0xae1240)
--Type <RET> for more, q to quit, c to continue without paging--c
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qobject.cpp:2206
#11 0x00007ffff4a19b18 in QWidget::~QWidget (this=0xac7100, __in_chrg=<optimized out>)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/widgets/kernel/qwidget.cpp:1537
#12 0x00007ffff687dba7 in KMainWindow::~KMainWindow (this=0xac7100, __in_chrg=<optimized out>)
    at /home/akseli/Repositories/kde/src/kxmlgui/src/kmainwindow.cpp:433
#13 0x00007ffff68f8d84 in KXmlGuiWindow::~KXmlGuiWindow
    (this=0xac7100, __vtt_parm=0x54b368 <VTT for DolphinMainWindow+8>, __in_chrg=<optimized out>)
    at /home/akseli/Repositories/kde/src/kxmlgui/src/kxmlguiwindow.cpp:217
#14 0x00000000004471db in DolphinMainWindow::~DolphinMainWindow
    (this=0xac7100, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /home/akseli/Repositories/kde/src/dolphin/src/dolphinmainwindow.cpp:223
#15 0x0000000000447234 in DolphinMainWindow::~DolphinMainWindow
    (this=0xac7100, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /home/akseli/Repositories/kde/src/dolphin/src/dolphinmainwindow.cpp:223
#16 0x00007ffff37f3419 in QObject::event (this=0xac7100, e=0x1034ad0)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qobject.cpp:1424
#17 0x00007ffff6880256 in KMainWindow::event (this=0xac7100, ev=0x1034ad0)
    at /home/akseli/Repositories/kde/src/kxmlgui/src/kmainwindow.cpp:905
#18 0x00007ffff68f8edb in KXmlGuiWindow::event (this=0xac7100, ev=0x1034ad0)
    at /home/akseli/Repositories/kde/src/kxmlgui/src/kxmlguiwindow.cpp:221
#19 0x0000000000448e25 in DolphinMainWindow::event (this=0xac7100, event=0x1034ad0)
    at /home/akseli/Repositories/kde/src/dolphin/src/dolphinmainwindow.cpp:562
#20 0x00007ffff49c2b38 in QApplicationPrivate::notify_helper
    (this=<optimized out>, receiver=0xac7100, e=0x1034ad0)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/widgets/kernel/qapplication.cpp:3290
#21 0x00007ffff37a0ba8 in QCoreApplication::notifyInternal2 (receiver=0xac7100, event=0x1034ad0)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qcoreapplication.cpp:1118
#22 0x00007ffff37a0dad in QCoreApplication::sendEvent (receiver=<optimized out>, event=<optimized out>)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qcoreapplication.cpp:1536
#23 0x00007ffff37a4aa5 in QCoreApplicationPrivate::sendPostedEvents
    (receiver=0x0, event_type=0, data=0x6355c0)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qcoreapplication.cpp:1898
#24 0x00007ffff37a4e1d in QCoreApplication::sendPostedEvents
    (receiver=<optimized out>, event_type=<optimized out>)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qcoreapplication.cpp:1757
#25 0x00007ffff3a410bf in postEventSourceDispatch (s=0x6b4da0)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qeventdispatcher_glib.cpp:243
#26 0x00007ffff1b11e5c in g_main_dispatch (context=0x7fffdc000ef0) at ../glib/gmain.c:3476
#27 g_main_context_dispatch_unlocked (context=0x7fffdc000ef0) at ../glib/gmain.c:4284
#28 0x00007ffff1b6cf18 in g_main_context_iterate_unlocked.isra.0
    (context=context@entry=0x7fffdc000ef0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4349
#29 0x00007ffff1b0fad3 in g_main_context_iteration (context=0x7fffdc000ef0, may_block=1)
    at ../glib/gmain.c:4414
#30 0x00007ffff3a4096f in QEventDispatcherGlib::processEvents (this=0x638c00, flags=...)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qeventdispatcher_glib.cpp:393
#31 0x00007ffff37ad9bb in QEventLoop::exec (this=this@entry=0x7fffffffc280, flags=..., flags@entry=...)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/global/qflags.h:34
#32 0x00007ffff37a97bd in QCoreApplication::exec ()
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/global/qflags.h:74
#33 0x000000000043f6ba in main (argc=1, argv=0x7fffffffd7e8)
    at /home/akseli/Repositories/kde/src/dolphin/src/main.cpp:253
Comment 1 Akseli Lahtinen 2024-01-10 09:22:50 UTC
Git commit 1a59905027e578e396216b1f11831c80ec87db4f by Akseli Lahtinen.
Committed on 10/01/2024 at 10:22.
Pushed by akselmo into branch 'master'.

terminalpanel.cpp: Set m_konsolePart to nullptr during exit signal

If Dolphin terminal is open, and one types `exit` there and then closes Dolphin, Dolphin crashes due to a dangling pointer.

Konsole KPart is deleting itself when Konsole session exits, but Dolphin tracks it as a child of the Terminal Panel. 
The Terminal Panel doesn't get destroyed when Konsole KPart does, and it tries to double free during children clean up.
(Thanks @sitter !) 

Setting `m_konsolePart` to `nullptr` during exit signal fixes this, since there is already check in place for that in the destructor.

M  +1    -0    src/panels/terminal/terminalpanel.cpp

https://invent.kde.org/system/dolphin/-/commit/1a59905027e578e396216b1f11831c80ec87db4f