Skip to content

Hold MainWin in pointer, to avoid error on exit.

Wuttke, Joachim requested to merge badfree into main

Under gdb, upon exiting Steca we got

==112127==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x7fffffffcc00 in thread T0
    #0 0x7ffff78ba3c8 in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:164
    #1 0x7ffff714e716 in MainWin::~MainWin() /G/sw/steca/gui/mainwin.cpp:118
    #2 0x7ffff536376e in QObject::event(QEvent*) (/lib/x86_64-linux-gnu/libQt6Core.so.6+0x16376e)
    #3 0x7ffff6182a52 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt6Widgets.so.6+0x182a52)
    #4 0x7ffff53278c7 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt6Core.so.6+0x1278c7)
    #5 0x7ffff5327aa6 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (/lib/x86_64-linux-gnu/libQt6Core.so.6+0x127aa6)
    #6 0x7ffff550e362  (/lib/x86_64-linux-gnu/libQt6Core.so.6+0x30e362)
    #7 0x7ffff4bda7a8 in g_main_context_dispatch (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x547a8)
    #8 0x7ffff4bdaa37  (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x54a37)
    #9 0x7ffff4bdaacb in g_main_context_iteration (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x54acb)
    #10 0x7ffff550bf8b in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (/lib/x86_64-linux-gnu/libQt6Core.so.6+0x30bf8b)
    #11 0x7ffff5331589 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (/lib/x86_64-linux-gnu/libQt6Core.so.6+0x131589)
    #12 0x7ffff532a6b7 in QCoreApplication::exec() (/lib/x86_64-linux-gnu/libQt6Core.so.6+0x12a6b7)
    #13 0x555555572d9e in main /G/sw/steca/main/steca.cpp:132
    #14 0x7ffff5046189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #15 0x7ffff5046244 in __libc_start_main_impl ../csu/libc-start.c:381
    #16 0x5555555707a0 in _start (/G/sw/steca/debug/bin/steca+0x1c7a0)

In my understanding, when app.exec() terminates, it tries to delete the MainWindow. Therefore, the MainWindow is now held in a pointer.

Edited by Wuttke, Joachim

Merge request reports

Loading