fix: avoid xdg_activation_v1 destroy on a torn-down display at exit#771
Merged
yixinshark merged 1 commit intoJun 9, 2026
Merged
Conversation
There was a problem hiding this comment.
Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
XdgActivationV1 was a function-local static (Meyers singleton). Its destructor runs at __cxa_finalize, after main() returns and ~QGuiApplication has already torn down the Wayland connection, so xdg_activation_v1::destroy() marshals a request onto an already-freed wl_proxy/wl_display and crashes (SIGSEGV in wl_map_insert_at). It is triggered on normal process exit, e.g. when the session exits during a VT/TTY switch. Make instance() heap-allocate the object and parent it to qApp (held via a non-owning QPointer) so it is destroyed within the Qt shutdown sequence rather than at static-destruction time. Also guard the destructor with qApp, since QCoreApplication::self is already null when qApp deletes its children, ensuring destroy() is never marshalled onto a dead wl_display. XdgActivationV1 原本是函数局部静态量(Meyers 单例),其析构发生在 __cxa_finalize, 即 main() 返回、~QGuiApplication 已销毁 Wayland 连接之后。此时调用 xdg_activation_v1::destroy() 会向已释放的 wl_proxy/wl_display 发送请求而崩溃 (SIGSEGV in wl_map_insert_at),在进程正常退出时触发,例如切换 VT/TTY 导致会话退出。 改为在 instance() 中堆分配对象并挂到 qApp(用非持有的 QPointer 持有),使其在 Qt 关闭流程中销毁,而非静态析构期;析构函数再加 qApp 守卫:qApp 删除子对象时 QCoreApplication::self 已为空,确保绝不会再向已销毁的 wl_display 发送 destroy()。 Log: avoid xdg_activation_v1 destroy on a torn-down display at exit Pms: BUG-346387 Change-Id: Ibd924692759de957b18b78ccb1fcb0968d4aa030
a3604b1 to
9e7b1b0
Compare
deepin pr auto review这段代码是对XdgActivationV1类的改进,主要关注了单例模式的生命周期管理和Qt应用程序退出时的安全性。以下是我的审查意见: 语法逻辑
代码质量
代码性能
代码安全
改进建议
总体而言,这次改进很好地解决了原代码中可能存在的生命周期管理问题,提高了代码的健壮性和安全性。 |
BLumia
approved these changes
Jun 9, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
Summary
DDEIntegration::XdgActivationV1was a function-local static (Meyers singleton). Its destructor runs at__cxa_finalize— aftermain()returns and~QGuiApplicationhas already torn down the Wayland connection — soxdg_activation_v1::destroy()marshals a request onto an already-freedwl_proxy/wl_displayand crashes (SIGSEGVinwl_map_insert_at).instance()now heap-allocates the object and parents it toqApp(held via a non-owningQPointer) so it is destroyed within Qt's shutdown sequence, not at static-destruction time. The destructor is additionally guarded withqApp(which is already null when qApp deletes its children), sodestroy()is never marshalled onto a deadwl_display.Crash backtrace (before fix)
Test plan
dde-shellcoredump incoredumpctlwith thexdg_activation_v1::destroyframe.