Skip to content

fix: avoid signal-handler deadlocks during session shutdown - #234

Open
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:fix/bug-378589-session-logout
Open

yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:fix/bug-378589-session-logout

Conversation

@yixinshark

@yixinshark yixinshark commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

POSIX signal handlers called SessionManager::doLogout(), which invokes Qt/D-Bus while interrupted code may hold their locks. Remove those handlers and retain crash/termination cleanup through the existing ExecStopPost and OnFailure systemd paths. Also remove the obsolete dde-dock.service stop call: the current Dock is dde-shell@DDE.service.

Desktop and Dock start independently. The paired tray target owns its ordering after the Dock; this PR adds no desktop-before-Dock or Dock-before-desktop constraint. Update the lifecycle document to match the current services.

移除信号处理函数中不安全的 Qt/D-Bus 调用,保留 systemd 对正常及异常退出的清理。删除旧 dde-dock 调用,保持桌面与 Dock 并行启动,并更新生命周期说明。

Validation

  • Qt6 build and existing CTest: 1/1 passed.
  • Systemd lifecycle fixtures with the paired tray change passed: parallel desktop/Dock startup, replacement-Dock restart, cancellation/failure recovery and shutdown ordering.
  • Repeated deployed login/logout checks on X11: latest five tray stops took 41–67 ms, and Dock stops took 20–36 ms. These are individual service stop times, not total logout latency.
  • Native Wayland logout remains unverified. The separately observed greeter wallpaper/DConfig teardown stall and window remnants are not addressed here.

Paired change: linuxdeepin/dde-tray-loader#523

Pms: BUG-378589

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yixinshark

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Sep 29, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR removes reentrant Qt/D-Bus signal handlers and the obsolete direct dock stop, delegating cleanup to systemd, and revises unit dependencies so the dock stops before the desktop while tray shutdown can proceed in parallel. Review the service ordering carefully alongside the companion dde-tray-loader change, and verify both startup synchronization and shutdown behavior.

Sequence diagram for systemd-managed session logout

sequenceDiagram
    participant Systemd
    participant SessionManager
    participant Dock
    participant Desktop

    Systemd->>SessionManager: stop
    SessionManager->>SessionManager: prepareLogout(force)
    Note over SessionManager: systemd retains ExecStopPost cleanup
    Systemd->>Dock: stop
    Dock-->>Systemd: stopped
    Systemd->>Desktop: stop
    Desktop-->>Systemd: stopped
Loading

File-Level Changes

Change Details Files
Eliminate unsafe logout-time signal handling and rely on systemd-managed cleanup.
  • Remove SIGINT/SIGABRT/SIGTERM/SIGSEGV handlers that invoked Qt/D-Bus logout logic from signal context.
  • Remove signal-handler initialization and related declarations/includes.
  • Remove the direct legacy dde-dock.service stop operation and its service constant.
  • Preserve the existing systemd ExecStopPost cleanup path.
src/dde-session/impl/sessionmanager.cpp
src/dde-session/impl/sessionmanager.h
src/utils/utils.h
Adjust systemd shutdown ordering so the shell/dock is stopped before the desktop without unnecessarily serializing tray shutdown.
  • Update the shell service dependency/order configuration to stop dde-shell@DDE.service before the desktop.
  • Remove direct ordering against the tray target while retaining companion tray readiness synchronization.
  • Update session-manager unit configuration supporting the revised lifecycle ordering.
systemd/dde-session-core.target.wants/dde-shell@DDE.service
systemd/dde-session-manager.service.in

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Remove signal handlers that invoke Qt and D-Bus from interrupted code.
Keep abnormal-exit cleanup in the existing systemd ExecStopPost and
OnFailure paths, and remove the obsolete dde-dock service stop call.
Keep desktop and Dock startup independent; let the tray target own its
ordering after the Dock. Document the current session lifecycle.

移除在被中断代码中调用 Qt 和 D-Bus 的信号处理函数,避免重入死锁。
异常退出清理继续由已有的 systemd ExecStopPost 和 OnFailure 路径完成,
删除旧 dde-dock 服务停止调用。保留桌面与 Dock 独立启动,由托盘 target
维护其与 Dock 的顺序关系,并更新会话生命周期说明。

Log: avoid signal-handler deadlocks during session shutdown
Pms: BUG-378589
Change-Id: I640d8c5541fee3df4bdb82bd789bacb8cd25a1f3
@yixinshark
yixinshark force-pushed the fix/bug-378589-session-logout branch from 37d7975 to 6bf7a8f Compare September 30, 2026 06:14
@yixinshark yixinshark changed the title fix: avoid logout deadlocks and stop dock before desktop fix: avoid signal-handler deadlocks during session shutdown Sep 30, 2026
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.

2 participants