Repository navigation
[6247] 修复切换更新渠道后重启应用更新时退出崩溃 - #4796
Merged
PinkMagicFly merged 1 commit intoNov 16, 2026
Merged
Conversation
PinkMagicFly
deleted the
pigmagicfly/6247/fix-updater-channel-switch-crash
branch
November 16, 2026 09:37
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.
问题描述
在 macOS 上将更新渠道从
stable切换到beta后,下载完成并点击确认立即重启应用更新时,进程在退出阶段触发EXC_BAD_ACCESS (SIGSEGV)(QThreadStorageData::get()空指针解引用),导致系统弹出崩溃错误弹窗。根因分析
updater-switch-chain-poll在下载就绪(st == 4)后调用cpp_updater_dialog_close()关闭下载等待弹窗,紧接着通过updater-question(QDialog::exec())弹出重启确认框,用户确认后直接走(safely-quit-TeXmacs)→tm_server_rep::quit()→exit(0)退出。cpp_updater_dialog_close()原先仅调用g_updater_dialog_host->close();但WA_DeleteOnClose在 Qt 中并非同步析构,而是投递外层loopLevel的QEvent::DeferredDelete。QDialog::exec()嵌套事件循环不会派发外层DeferredDelete,导致exit(0)触发__cxa_finalize_ranges时 Qt 静态 TLS(QThreadStorageData/QOpenGLContext)已被释放,随后sendPostedEvents才析构该QDialog及其子控件QQuickWidget(QSurface::~QSurface()→QOpenGLContext::currentContext()→QThreadStorageData::get()),触发SIGSEGV。修改内容
src/Plugins/Qt/QTMQmlDialog.cpp:参照同文件中cpp_wait_dialog_close()的做法,在cpp_updater_dialog_close()中先置空g_updater_dialog_host再同步delete host,确保宿主立即析构。tests/Plugins/Qt/qml_load_test.cpp:新增TestQmlLoad::test_updater_dialog_close_destroys_synchronously回归测试,验证cpp_updater_dialog_close()同步析构宿主且重复调用幂等安全。验证情况
xmake b --yes qml_load_test && xmake r qml_load_test:通过(41 passed, 0 failed)gf fmt --changed-since=main:通过