<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>479596</bug_id>
          
          <creation_ts>2024-01-10 08:57:08 +0000</creation_ts>
          <short_desc>Dolphin crashes after terminal is closed with &quot;exit&quot; and Dolphin is then closed</short_desc>
          <delta_ts>2024-01-10 09:33:08 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>dolphin</product>
          <component>panels: terminal</component>
          <version>24.01.85</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>qt6</keywords>
          <priority>NOR</priority>
          <bug_severity>crash</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Akseli Lahtinen">akselmo</reporter>
          <assigned_to name="Dolphin Bug Assignee">dolphin-bugs-null</assigned_to>
          <cc>dolphin-bugs-null</cc>
          
          <cf_commitlink>https://invent.kde.org/system/dolphin/-/commit/1a59905027e578e396216b1f11831c80ec87db4f</cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2279094</commentid>
    <comment_count>0</comment_count>
    <who name="Akseli Lahtinen">akselmo</who>
    <bug_when>2024-01-10 08:57:08 +0000</bug_when>
    <thetext>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&apos;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 &lt;QObject::staticMetaObject@Qt_6&gt;, 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=&lt;optimized out&gt;, receiver=0xb20ee0, slot=0x7fffffffb8e0, senderMetaObject=0x5d5120 &lt;QObject::staticMetaObject@Qt_6&gt;)
    at /usr/src/debug/qt6-qtbase-6.6.0-6.fc39.x86_64/src/corelib/kernel/qobject.cpp:5277
#3  0x00000000004b98a2 in QObject::disconnect&lt;void (QObject::*)(QObject*), void (TerminalPanel::*)()&gt;
    (sender=0x112f9f0, signal=(void (QObject::*)(QObject * const, QObject *)) 0x438490 &lt;QObject::destroyed(QObject*)@plt&gt;, receiver=0xb20ee0, slot=(void (TerminalPanel::*)(TerminalPanel * const)) 0x4b663a &lt;TerminalPanel::terminalExited()&gt;) at /usr/include/qt6/QtCore/qobject.h:276
#4  0x00000000004b64fd in TerminalPanel::~TerminalPanel (this=0xb20ee0, __in_chrg=&lt;optimized out&gt;)
    at /home/akseli/Repositories/kde/src/dolphin/src/panels/terminal/terminalpanel.cpp:53
#5  0x00000000004b6566 in TerminalPanel::~TerminalPanel (this=0xb20ee0, __in_chrg=&lt;optimized out&gt;)
    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=&lt;optimized out&gt;)
    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=&lt;optimized out&gt;)
    at /home/akseli/Repositories/kde/src/dolphin/src/dolphindockwidget.cpp:55
#9  0x0000000000521082 in DolphinDockWidget::~DolphinDockWidget (this=0xa76040, __in_chrg=&lt;optimized out&gt;)
    at /home/akseli/Repositories/kde/src/dolphin/src/dolphindockwidget.cpp:55
#10 0x00007ffff37fa71d in QObjectPrivate::deleteChildren (this=this@entry=0xae1240)
--Type &lt;RET&gt; 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=&lt;optimized out&gt;)
    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=&lt;optimized out&gt;)
    at /home/akseli/Repositories/kde/src/kxmlgui/src/kmainwindow.cpp:433
#13 0x00007ffff68f8d84 in KXmlGuiWindow::~KXmlGuiWindow
    (this=0xac7100, __vtt_parm=0x54b368 &lt;VTT for DolphinMainWindow+8&gt;, __in_chrg=&lt;optimized out&gt;)
    at /home/akseli/Repositories/kde/src/kxmlgui/src/kxmlguiwindow.cpp:217
#14 0x00000000004471db in DolphinMainWindow::~DolphinMainWindow
    (this=0xac7100, __in_chrg=&lt;optimized out&gt;, __vtt_parm=&lt;optimized out&gt;)
    at /home/akseli/Repositories/kde/src/dolphin/src/dolphinmainwindow.cpp:223
#15 0x0000000000447234 in DolphinMainWindow::~DolphinMainWindow
    (this=0xac7100, __in_chrg=&lt;optimized out&gt;, __vtt_parm=&lt;optimized out&gt;)
    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=&lt;optimized out&gt;, 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=&lt;optimized out&gt;, event=&lt;optimized out&gt;)
    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=&lt;optimized out&gt;, event_type=&lt;optimized out&gt;)
    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=&lt;optimized out&gt;) 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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2279105</commentid>
    <comment_count>1</comment_count>
    <who name="Akseli Lahtinen">akselmo</who>
    <bug_when>2024-01-10 09:22:50 +0000</bug_when>
    <thetext>Git commit 1a59905027e578e396216b1f11831c80ec87db4f by Akseli Lahtinen.
Committed on 10/01/2024 at 10:22.
Pushed by akselmo into branch &apos;master&apos;.

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&apos;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</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>