Skip to content

fix(amule): apply wxWebSession-cleanup _Exit workaround on all platforms - #159

Merged
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/wxwebsession-dtor-crash-on-exit
Jun 14, 2026
Merged

fix(amule): apply wxWebSession-cleanup _Exit workaround on all platforms#159
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/wxwebsession-dtor-crash-on-exit

Conversation

@got3nks

@got3nks got3nks commented Jun 14, 2026

Copy link
Copy Markdown

Fixes #18 (cardpuncher's Fedora 44 KDE Flatpak shutdown crash, and any other Linux user hitting SIGABRT on close after an HTTP fetch).

What's happening

The std::_Exit(0) block in OnExit() was added in a prior commit to dodge a wxWebSessionURLSession dtor bug under wx 3.3.2 (macOS, NSURLSession reference-counting mismatch). Turns out the Linux backend (wxWebSessionCURL, wx 3.2.6) hits the same class of cleanup-time race:

  1. main() returns, wxEntryCleanup runs wx module destructors.
  2. wxWebSessionCURL::~wxWebSessionCURL calls curl_multi_cleanup.
  3. libcurl's cleanup invokes the registered socket callback (wxWebSessionCURL::SocketCallback) to drop tracked sockets.
  4. That callback dereferences session state the dtor's earlier steps already tore down.
  5. wxASSERT fires → wxFatalSignalHandlerraise(SIGABRT).

Verified end-to-end with a debug-symbol Flatpak + gdb on a user-supplied core, fully symbolicated:

#19 main                                amule-gui.cpp:98
#18 wxEntry                             wx/init.cpp:500
#17 wxEntryCleanup                      wx/init.cpp:205
#16 wxModule::CleanUpModules            wx/module.cpp:191
#15 wxModule::DoCleanUpModules          wx/module.cpp:200
#14 wxRefCounterMT::DecRef
    wxWebSession::Close                 wx/webrequest.cpp:1074
#13 wxWebSessionCURL::~wxWebSessionCURL wx/webrequest_curl.cpp:932
#12 wxWebSessionCURL::~wxWebSessionCURL wx/webrequest_curl.cpp:929
#11-#6 libcurl curl_multi_cleanup
#5  wxWebSessionCURL::SocketCallback    wx/webrequest_curl.cpp:1047
#4  raise()
#3  wxFatalSignalHandler                wx/unix/utilsunx.cpp:1523
#0  abort

What this PR does

Drops the #if defined(__APPLE__) guard around the existing std::_Exit(0) so it runs on every platform. Same justification holds everywhere: by this point in OnExit() we have saved state, joined threads, and flushed logs — nothing aMule-owned remains to clean up. _Exit bypasses atexit and static destructors uniformly, so the buggy wx dtor never runs and the process terminates cleanly.

The block stays time-bounded — comment notes "remove once the upstream wx fix lands in a release we depend on".

Test plan

  • macOS: existing behaviour preserved (was already taking this path).
  • Linux: reproduces cleanly with a debug-symbol Flatpak; same exit path now applies.
  • Windows: not observed to crash but the same code path runs; should be a no-op behaviour change since wx cleanup wouldn't bite there.

…atforms

The macOS-only `std::_Exit(0)` block in OnExit() was added to dodge a
wxWebSessionURLSession dtor bug under wx 3.3.2. Turns out the
Linux backend (wxWebSessionCURL, wx 3.2.6) hits the same class of
shutdown crash: its dtor calls curl_multi_cleanup, libcurl invokes the
registered socket callback (wxWebSessionCURL::SocketCallback) to drop
tracked sockets, and that callback dereferences session state the
dtor's earlier steps have already torn down. wxASSERT fires,
wxFatalSignalHandler raise(SIGABRT)s.

Verified with a debug-symbol Flatpak + gdb on a user-supplied core,
fully symbolicated:

    amule-project#19 main                                amule-gui.cpp:98
    amule-project#18 wxEntry                             wx/init.cpp:500
    amule-project#17 wxEntryCleanup                      wx/init.cpp:205
    amule-project#16 wxModule::CleanUpModules            wx/module.cpp:191
    amule-project#15 wxModule::DoCleanUpModules          wx/module.cpp:200
    amule-project#14 wxRefCounterMT::DecRef
        wxWebSession::Close                 wx/webrequest.cpp:1074
    amule-project#13 wxWebSessionCURL::~wxWebSessionCURL wx/webrequest_curl.cpp:932
    amule-project#12 wxWebSessionCURL::~wxWebSessionCURL wx/webrequest_curl.cpp:929
    amule-project#11-amule-project#6 libcurl curl_multi_cleanup
    amule-project#5  wxWebSessionCURL::SocketCallback    wx/webrequest_curl.cpp:1047
    amule-project#4  raise()
    amule-project#3  wxFatalSignalHandler                wx/unix/utilsunx.cpp:1523
    #0  abort

Same justification used for the macOS guard applies on every
platform: by this point in OnExit we have saved state, joined
threads, and flushed logs -- nothing aMule-owned remains to clean up.
_Exit bypasses atexit and static destructors uniformly, so the buggy
wx dtor never runs and the process terminates cleanly.

Remove this once the upstream wx fix lands in a release we depend on.

Reported in amule-project#18.
@got3nks
got3nks merged commit 78f62c0 into amule-org:master Jun 14, 2026
10 checks passed
@got3nks
got3nks deleted the fix/wxwebsession-dtor-crash-on-exit branch June 14, 2026 20:42
got3nks added a commit that referenced this pull request Jul 3, 2026
…#285)

The monolithic app already bypasses wx's static-destructor / module
cleanup in CamuleGuiApp::OnExit to avoid a crash in the platform
wxWebSession destructor at quit (#18, PR #159). The
remote GUI uses a separate app class (CamuleRemoteGuiApp) whose OnExit
never got the same guard, so amulegui still SIGABRTs on quit in
WebRequestModule::OnExit -> wxWebSessionURLSession::~ on macOS
(wx 3.3.2). It links wxWebRequest too, so it hits the identical path.

Apply the same std::_Exit(0) after amulegui's own cleanup (timer,
sockets) has run.
Cflsft pushed a commit to Cflsft/amule that referenced this pull request Jul 6, 2026
…amule-org#285)

The monolithic app already bypasses wx's static-destructor / module
cleanup in CamuleGuiApp::OnExit to avoid a crash in the platform
wxWebSession destructor at quit (amule-org#18, PR amule-org#159). The
remote GUI uses a separate app class (CamuleRemoteGuiApp) whose OnExit
never got the same guard, so amulegui still SIGABRTs on quit in
WebRequestModule::OnExit -> wxWebSessionURLSession::~ on macOS
(wx 3.3.2). It links wxWebRequest too, so it hits the identical path.

Apply the same std::_Exit(0) after amulegui's own cleanup (timer,
sockets) has run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flatpack binaries issues on Alpine and Fedora

1 participant