contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.38k stars 102 forks source link

Qt(!) triggers session destruction, causing Contour to orderly terminate (unintentionally). #1312

Closed christianparpart closed 10 months ago

christianparpart commented 10 months ago

This is the stack trace when TerminalSession is about to be destructed:

(lldb) bt
* thread #1, name = 'contour', stop reason = breakpoint 1.1
    frame #0: 0x0000000000554e88 contour`contour::TerminalSession::~TerminalSession(this=0x0000000000c1c9d0) at TerminalSession.cpp:191
    frame #1: 0x0000000000555054 contour`contour::TerminalSession::~TerminalSession(this=0x0000000000c1c9d0) at TerminalSession.cpp:190:1
    frame #2: 0x0000fffff53b0298 libQt6Core.so.6`QObject::event(QEvent*) + 88
    frame #3: 0x0000fffff776d3e8 libQt6Widgets.so.6`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 88
    frame #4: 0x0000fffff5358bf0 libQt6Core.so.6`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 316
    frame #5: 0x0000fffff535c8f8 libQt6Core.so.6`QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 612
    frame #6: 0x0000fffff56016fc libQt6Core.so.6`postEventSourceDispatch(_GSource*, int (*)(void*), void*) + 44
    frame #7: 0x0000fffff4600310 libglib-2.0.so.0`g_main_context_dispatch_unlocked.lto_priv.0 + 400
    frame #8: 0x0000fffff465e59c libglib-2.0.so.0`g_main_context_iterate_unlocked.isra.0 + 664
    frame #9: 0x0000fffff45fdac8 libglib-2.0.so.0`g_main_context_iteration + 56
    frame #10: 0x0000fffff5600eac libQt6Core.so.6`QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 88
    frame #11: 0x0000fffff5365dc4 libQt6Core.so.6`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 564
  * frame #12: 0x0000fffff53616b8 libQt6Core.so.6`QCoreApplication::exec() + 152
    frame #13: 0x000000000054a880 contour`contour::ContourGuiApp::terminalGuiAction(this=0x0000ffffffffeae0) at ContourGuiApp.cpp:419:15
    frame #14: 0x0000000000624c24 contour`crispy::app::run(int, char const**) [inlined] std::function<int ()>::operator()(this=<unavailable>) const at std_function.h:591:9
    frame #15: 0x0000000000624c1c contour`crispy::app::run(this=0x0000ffffffffeae0, argc=<unavailable>, argv=<unavailable>) at App.cpp:229:24
    frame #16: 0x00000000004fd2c0 contour`main(argc=<unavailable>, argv=<unavailable>) at main.cpp:136:16
    frame #17: 0x0000fffff4be09dc libc.so.6`__libc_start_call_main + 124
    frame #18: 0x0000fffff4be0ab0 libc.so.6`__libc_start_main@@GLIBC_2.34 + 156
    frame #19: 0x00000000004e3ab0 contour`_start + 48

I forced that by spamming font resizing (modifier + mouse wheel up/down event excess), and if done long enough, you'll eventually see Contour terminate cleanly. No error messages. It looks like Qt is actually triggering TerminalSession to be destroyed. It is unclear why though. Maybe because it's exposed to QML and subject to be GC'd? If so, that's hilarious 💥.