wxMaxima-developers / wxmaxima

A gui for the computer algebra system Maxima built with wxWidgets
https://wxMaxima-developers.github.io/wxmaxima/
Other
459 stars 96 forks source link

Crash on closing the first of two windows if --single_process is active #1889

Closed gunterkoenigsmann closed 5 months ago

gunterkoenigsmann commented 5 months ago

I believe that is the error we had for years, but now we trigger it reliably. Seems to be the following:

gunterkoenigsmann commented 5 months ago

git bisect seems to tell that the first bad commit is 534e4e00fae93083f2cd0529e4459fd99a5b3919 - which doesn't make any sense.

gunterkoenigsmann commented 5 months ago

Another bisect blames a8deb783c574db3440ae07b4bd193fd2620b75bc - which meant changes in Maxima.cpp - which actually really sends events to wxMaxima and which is called in the window's destructor. If we should unsubscribe to maxima's signals before closing maxima?

gunterkoenigsmann commented 5 months ago

Found something that acknowledges my suspicion that this commit was a red herring and that the problem merely has gone worse when wxMaxima has grown faster: If I comment all our QueueEvent() commands the problem goes away => somehow some of our code sends the event that arrives after the main window was closed.

gunterkoenigsmann commented 5 months ago

Disabling all sidebars didn't stop this issue from occurring. ...and it seems like a wxProcess on closing seems to send the message that crashes the program - but only if wxMaxima is closed early enough to trigger the problem.

gunterkoenigsmann commented 5 months ago

The crash only happens if the application is closed shortly after start-up and valgrind tells:

==11762== Invalid read of size 8
==11762==    at 0x559C1B1: UnknownInlinedFun (event.h:1236)
==11762==    by 0x559C1B1: wxEvtHandler::DoTryChain(wxEvent&) (event.cpp:1592)
==11762==    by 0x559E691: wxEvtHandler::ProcessEvent(wxEvent&) (event.cpp:1534)
==11762==    by 0x5507347: wxProcess::OnTerminate(int, int) (process.cpp:94)
==11762==    by 0x558AA07: wxExecuteData::OnExit(int) (utilsunx.cpp:1799)
==11762==    by 0x558ED6D: wxExecuteData::OnSomeChildExited(int) (utilsunx.cpp:1730)
==11762==    by 0x5568AF0: wxAppConsole::CheckSignal() (appunix.cpp:125)
==11762==    by 0x4EC196B: wx_on_channel_event (evtloop.cpp:130)
==11762==    by 0x68041BD: g_main_dispatch.lto_priv.0 (gmain.c:3476)
==11762==    by 0x68625FE: UnknownInlinedFun (gmain.c:4284)
==11762==    by 0x68625FE: g_main_context_iterate_unlocked.isra.0 (gmain.c:4349)
==11762==    by 0x6804CA6: g_main_loop_run (gmain.c:4551)
==11762==    by 0x5EB2B04: gtk_main (gtkmain.c:1329)
==11762==    by 0x4EBAF34: wxGUIEventLoop::DoRun() (evtloop.cpp:61)
gunterkoenigsmann commented 5 months ago

wxExecuteData::OnSomeChildExited(int) is called, if wxAppConsole::CheckSignal() detects that a child process has exited.

We only have very few child processes:

Should be very easy. But somehow I still don't find out how to get rid of this problem.

gunterkoenigsmann commented 5 months ago

Resolved with 287ca626a876db562dcd8af3d1cb708535f59669.