Fix Linux segfault on application exit (dead GL context in global destructors) - #577
Open
Arm4g3ddon wants to merge 2 commits into
Open
Fix Linux segfault on application exit (dead GL context in global destructors)#577Arm4g3ddon wants to merge 2 commits into
Arm4g3ddon wants to merge 2 commits into
Conversation
added 2 commits
July 3, 2026 11:39
On exit, GUI_App::OnExit() called std::exit(0), which drives the C++
global/static destructors. Static GLModel instances are destroyed there and
call GLModel::RenderData::release() -> glDeleteBuffers() after the GL/GTK
context has already been torn down, dereferencing a stale GL entry point and
segfaulting. breakpad's signal handler then double-faults on top.
Backtrace (Linux, 7.2.x):
GUI_App::OnExit -> std::exit -> <global dtors> -> GLModel::~GLModel
-> GLModel::reset -> RenderData::release -> glDeleteBuffers -> SIGSEGV
All persistent state is already saved during the window-close sequence and
wxApp::OnExit(), so on Linux terminate via std::_Exit(0) to skip the
global-destructor teardown. Windows/macOS keep std::exit(0).
dumpCallback() runs from breakpad's signal handler but performs throwing boost::filesystem operations (rename/create_directories). When one throws (e.g. missing crash-dump dir), the exception unwinds out of the signal handler and double-faults into a second, harder crash, losing the minidump. Wrap the body in a catch-all so no exception can escape the handler.
Author
|
Still reproducible in Creality's temporary Linux build Coredump top frames (5251, stripped binary, but the signature matches): Same pattern as the traced cause here: an exception thrown out of the global-destructor teardown / breakpad signal handler on exit. So this is orthogonal to the read-only fix and still needs merging.
|
lolli42
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Linux, Creality Print segfaults on every exit (reproducible across 7.0.x → 7.2.0). systemd records a
SIGSEGVcoredump each time the app is closed.The
coredumpctltraces are truncated (the unwinder itself crashes), and a straylibjavascriptcoregtkframe makes it look WebKit-related. A full backtrace against an unstripped build shows the real cause:GUI_App::OnExit()ends withstd::exit(0), which drives the C++ global/static destructors. StaticGLModelinstances are torn down there and callRenderData::release() -> glDeleteBuffers()after the GL/GTK context has already been destroyed, so the GL entry point is stale and dereferencing it faults. breakpad's signal handler then double-faults on top (see second commit).Fix
1. Skip the global-destructor teardown on Linux exit. All persistent state (AppConfig, presets) is already saved during the window-close sequence and
wxApp::OnExit(), so there is nothing left to flush by the time we reach the end ofOnExit(). On Linux, terminate viastd::_Exit(0)instead ofstd::exit(0)to avoid running the global destructors that touch a dead GL context. Windows/macOS are unchanged (#ifdef __linux__).2. Make
dumpCallbackexception-safe. It runs from breakpad's signal handler but performs throwingboost::filesystemoperations (rename,create_directories). When one throws (e.g. the crash-dump dir is missing) the exception unwinds out of the signal handler and double-faults into a second, harder crash, losing the minidump. The body is now wrapped in a catch-all so no exception can escape the handler.Testing
Built for Linux (Ubuntu 24.04 / GCC 13) and run on Arch Linux + X11. Before: a
SIGSEGVcoredump on every exit. After: the app exits cleanly, no coredump.Both changes are Linux-only in effect and don't alter Windows/macOS behavior.