Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

SimulIDE crashes on closing serial monitor

2 posters

Go down  Message [Page 1 of 1]

oddsignals



This occurs in all versions starting at 0.4.13-SR3 and upwards, including latest 0.5.15-RC2. Does not occur in 0.4.13-SR2 and older.

Steps to reproduce:

1. Open SimulIDE
2. Drag AVR microcontroller atmega328 to schematic
3. Right-click component and click "Open Serial Monitor"
4. Close serial monitor window

Result: SimulIDE crashes.

Same occurs when opening a project saved while serial monitor window was open, if I close the serial monitor window SimulIDE crashes.

Tested on x64 Linux.

EDIT: Same issue as reported by user wallysalami in the thread "Simulide crashes on serial monitor", but different from issue topic starter TimFisch had (which should be fixed in 0.5.15-RC2).

arcachofo

arcachofo

Hmm.. i can't reproduce the issue.

Here in 0.4.13-SR5, but works the same in others.
I tried with simulation ON/OFF, closing while simulating, deleting atmega...
Check if i'm doing the steps properly:

SimulIDE crashes on closing serial monitor Serter10

chicodorea likes this post

oddsignals



Yes, those are the exact same steps I'm following, but here it crashes. Simulation running or not doesn't matter. I'll do some more digging and see if I can find out the cause of the crash.

oddsignals



I installed qt debug symbols and sources, made a debug build of 0.4.13-SR5 and got a core dump. It segfaults in the close window event handler. Backtrace is below in case it helps. qt version installed here is 5.14.2.

Code:

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./simulide'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f385d4dbab8 in QWindow::isTopLevel (this=this@entry=0xf21010) at kernel/qwindow.cpp:747
747    return d->parentWindow == 0;
[Current thread is 1 (Thread 0x7f385929d340 (LWP 155931))]
(gdb) bt
#0  0x00007f385d4dbab8 in QWindow::isTopLevel() const (this=this@entry=0xf21010) at kernel/qwindow.cpp:747
#1  0x00007f385d4dee37 in QWindowPrivate::maybeQuitOnLastWindowClosed() (this=this@entry=0x18865a0) at kernel/qwindow.cpp:2631
#2  0x00007f385d4e3895 in QWindow::event(QEvent*) (this=this@entry=0x1886540, ev=ev@entry=0x7ffdb357da40)
    at kernel/qwindow.cpp:2331
#3  0x00007f385dd29efb in QWidgetWindow::event(QEvent*) (this=0x1886540, event=0x7ffdb357da40) at kernel/qwidgetwindow.cpp:254
#4  0x00007f385dccd013 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
    (this=<optimized out>, receiver=0x1886540, e=0x7ffdb357da40) at kernel/qapplication.cpp:3685
#5  0x00007f385cdfd1ca in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x1886540, event=0x7ffdb357da40)
    at ../../include/QtCore/../../src/corelib/kernel/qobject.h:153
#6  0x00007f385d4d41ed in QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent*) ()
    at /usr/include/c++/10/bits/atomic_base.h:420
#7  0x00007f385d4ad2bb in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
    (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1170
#8  0x00007f385896135e in xcbSourceDispatch(GSource*, GSourceFunc, gpointer) (source=<optimized out>)
    at qxcbeventdispatcher.cpp:105
#9  0x00007f385bab14db in g_main_dispatch (context=0x7f3850005000) at ../../../glib/gmain.c:3325
#10 g_main_context_dispatch (context=0x7f3850005000) at ../../../glib/gmain.c:4016
#11 0x00007f385bab1788 in g_main_context_iterate
    (context=context@entry=0x7f3850005000, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../../../glib/gmain.c:4092
#12 0x00007f385bab1853 in g_main_context_iteration (context=0x7f3850005000, may_block=may_block@entry=1)
    at ../../../glib/gmain.c:4157
#13 0x00007f385ce54843 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x1145180, flags=...)
    at kernel/qeventdispatcher_glib.cpp:423
#14 0x00007f385cdfba4b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7ffdb357dc90, flags=...,
    flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:136
#15 0x00007f385ce03fc6 in QCoreApplication::exec() () at ../../include/QtCore/../../src/corelib/global/qflags.h:118
#16 0x000000000044fc2a in main(int, char**) (argc=1, argv=0x7ffdb357df18) at ../src/main.cpp:89

oddsignals



Arcachofo, which QT version do you have installed? It seems like the crashing isTopLevel() check was added in January 2019, around v5.12.2:

https://github.com/qt/qtbase/commit/b782004149610d5c6af27e12d788acfb213b84d0

arcachofo

arcachofo

I'm using 5.5.1

iI will have a look with a newer version and see if i can reproduce the issue.

arcachofo

arcachofo

I could not reproduce the issue with Qt 5.9.5.

But i'm almost sure where is the problem:
File: simulide_0.4.13-SR5/src/gui/terminalwidget/terminalwidget.cpp
Coment out line 177 and see if that solves the problem:

Code:
void TerminalWidget::closeEvent( QCloseEvent* event )
{
    m_serComp->slotClose();
    //QWidget::closeEvent( event );
}

oddsignals



I believe you might need qt 5.12.2 or newer for it to crash.

Commenting out the closeEvent line doesn't help unfortunately, it still crashes. However, if I comment out line 176 like this:

Code:

void TerminalWidget::closeEvent( QCloseEvent* event )
{
    //m_serComp->slotClose();
    QWidget::closeEvent( event );
}

it closes the terminal normally and no longer crashes. But I guess that might create a resource leak since removeComp() will no longer be called?

EDIT: I see the m_serComp->slotClose(); line was added in 0.4.13-SR3, which is the first version where the crash occurs here. I assume it fixes "Serial Monitor not properly deleted" listed in the changelog

arcachofo

arcachofo

EDIT: I see the m_serComp->slotClose(); line was added in 0.4.13-SR3, which is the first version where the crash occurs here. I assume it fixes "Serial Monitor not properly deleted" listed in the changelog
Yes, before that, the widget was deleted but the component itself wasn't, so it was saved to circuit file.

I don't have Qt 5.12.2 currently, and i shoould install a newer version of my OS to get it.
it would be great If you could test this solution, if not i will install  what is needed.

Attached files with possible solution.
Just merge attached src folder with src folder in your sources (0.4.13-SR5).
Attachments
SimulIDE crashes on closing serial monitor Attachmentsrc.zip
You don't have permission to download attachments.
(6 Kb) Downloaded 3 times

oddsignals



The fix you attached works - closing the serial monitor now works correctly. The component is also still removed from the circuit file if you save the project after closing it.

However, a smaller bug now appears after the fix - if you close the main SimulIDE window while the serial monitor is open, the application crashes with a segfault instead of exiting cleanly:

Code:
#0  0x000000000046878e in Circuit::removeComp (this=0x2d61590, comp=0x311a810) at ../src/gui/circuitwidget/circuit.cpp:720
720    comp->remove();
[Current thread is 1 (Thread 0x7f55c4618340 (LWP 769256))]
(gdb) bt
#0  0x000000000046878e in Circuit::removeComp(Component*) (this=0x2d61590, comp=0x311a810)
    at ../src/gui/circuitwidget/circuit.cpp:720
#1  0x0000000000532f18 in TerminalWidget::closeEvent(QCloseEvent*) (this=0x3022000, event=0x7ffc69ebf6c0)
    at ../src/gui/terminalwidget/terminalwidget.cpp:178
#2  0x00007f55c908930e in QWidget::event(QEvent*) (this=0x3022000, event=0x7ffc69ebf6c0) at kernel/qwidget.cpp:9033
#3  0x00007f55c9048013 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
    (this=<optimized out>, receiver=0x3022000, e=0x7ffc69ebf6c0) at kernel/qapplication.cpp:3685
#4  0x00007f55c81781ca in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x3022000, event=0x7ffc69ebf6c0)
    at ../../include/QtCore/../../src/corelib/kernel/qobject.h:153
#5  0x00007f55c9084685 in QWidgetPrivate::close_helper(QWidgetPrivate::CloseMode)
    (mode=QWidgetPrivate::CloseWithSpontaneousEvent, this=0x2ce0420) at kernel/qwidget.cpp:8252
#6  QWidgetPrivate::close_helper(QWidgetPrivate::CloseMode)
    (this=0x2ce0420, mode=mode@entry=QWidgetPrivate::CloseWithSpontaneousEvent) at kernel/qwidget.cpp:8237
#7  0x00007f55c90a4ed6 in QWidgetWindow::handleCloseEvent(QCloseEvent*) (event=0x7ffc69ebf820, this=0x3179510)
    at ../../include/QtWidgets/../../src/widgets/kernel/qwidget.h:132
#8  QWidgetWindow::event(QEvent*) (this=0x3179510, event=0x7ffc69ebf820) at kernel/qwidgetwindow.cpp:253
#9  0x00007f55c9048013 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
    (this=<optimized out>, receiver=0x3179510, e=0x7ffc69ebf820) at kernel/qapplication.cpp:3685
#10 0x00007f55c81781ca in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x3179510, event=0x7ffc69ebf820)
    at ../../include/QtCore/../../src/corelib/kernel/qobject.h:153
#11 0x00007f55c884f1ed in QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent*) (e=0x306ec40)
    at /usr/include/c++/10/bits/atomic_base.h:420
#12 QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent*) (e=0x306ec40)
    at kernel/qguiapplication.cpp:2550
#13 0x00007f55c88287b5 in QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::SynchronousDelivery>(QWindowSystemInterfacePrivate::WindowSystemEvent*) (ev=0x306ec40) at kernel/qwindowsysteminterface.cpp:105
#14 0x00007f55c9049c13 in QApplicationPrivate::tryCloseAllWidgetWindows(QList<QWindow*>*)
    (processedWindows=processedWindows@entry=0x7ffc69ebf8f0) at kernel/qapplication.cpp:1782
#15 0x00007f55c9049d59 in QApplication::closeAllWindows() () at kernel/qapplication.cpp:1820
#16 0x00007f55c904b765 in QApplication::event(QEvent*) (this=0x7ffc69ebfd50, e=0x2eee040) at kernel/qapplication.cpp:1861
#17 0x00007f55c9048013 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
    (this=<optimized out>, receiver=0x7ffc69ebfd50, e=0x2eee040) at kernel/qapplication.cpp:3685
#18 0x00007f55c81781ca in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x7ffc69ebfd50, event=0x2eee040)
    at ../../include/QtCore/../../src/corelib/kernel/qobject.h:153
#19 0x00007f55c817abc1 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*)
    (receiver=0x0, event_type=0, data=0x250cc70) at kernel/qcoreapplication.cpp:1815
#20 0x00007f55c81d01c7 in postEventSourceDispatch(GSource*, GSourceFunc, gpointer) (s=0x26b5e90)
    at kernel/qeventdispatcher_glib.cpp:277
#21 0x00007f55c6e2c4db in g_main_dispatch (context=0x7f55bc005000) at ../../../glib/gmain.c:3325
#22 g_main_context_dispatch (context=0x7f55bc005000) at ../../../glib/gmain.c:4016
#23 0x00007f55c6e2c788 in g_main_context_iterate
    (context=context@entry=0x7f55bc005000, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../../../glib/gmain.c:4092
#24 0x00007f55c6e2c853 in g_main_context_iteration (context=0x7f55bc005000, may_block=may_block@entry=1)
    at ../../../glib/gmain.c:4157
#25 0x00007f55c81cf843 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x2711780, flags=...)
    at kernel/qeventdispatcher_glib.cpp:423
#26 0x00007f55c8176a4b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7ffc69ebfcc0, flags=...,
    flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:136
#27 0x00007f55c817efc6 in QCoreApplication::exec() () at ../../include/QtCore/../../src/corelib/global/qflags.h:118
#28 0x000000000044fc2a in main(int, char**) (argc=1, argv=0x7ffc69ebff48) at ../src/main.cpp:89

arcachofo

arcachofo

The fix you attached works - closing the serial monitor now works correctly. The component is also still removed from the circuit file if you save the project after closing it.
That is good news!

However, a smaller bug now appears after the fix - if you close the main SimulIDE window while the serial monitor is open, the application crashes with a segfault instead of exiting cleanly:
No problem, this is not the complete solution, just to know what is causing the crash.
Also if you delete the atmega without closing Serial Monitor first, then Serial Monitor will not close.
But now that i know the origin of the crash, i can create a complete solution.

Thank you very much for your help!

oddsignals



arcachofo wrote:
No problem, this is not the complete solution, just to know what is causing the crash.
Also if you delete the atmega without closing Serial Monitor first, then Serial Monitor will not close.
But now that i know the origin of the crash, i can create a complete solution.

Thank you very much for your help!
Happy to help - thank you for looking into this and all your work on SimulIDE!

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum