Skip to content

fix(session): guard null active session in xwayland primary output sync - #1306

Open
glyvut wants to merge 1 commit into
linuxdeepin:masterfrom
glyvut:fix/xway-sync-null-active-session
Open

fix(session): guard null active session in xwayland primary output sync#1306
glyvut wants to merge 1 commit into
linuxdeepin:masterfrom
glyvut:fix/xway-sync-null-active-session

Conversation

@glyvut

@glyvut glyvut commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Check the weak_ptr lock result before dereferencing the active session. When an output is removed, primaryOutputChanged is delivered synchronously; if the active session was already reset (e.g. after a logind session was removed), calling ->xwayland() on the null session crashes the compositor.

输出移除时同步触发primaryOutputChanged,若活动会话已被重置,
对空指针调用->xwayland()会导致合成器崩溃,增加空指针守卫。

Log: 修复输出移除时活动会话为空导致的崩溃

Summary by Sourcery

Bug Fixes:

  • Prevent compositor crashes when the active session is unavailable during Xwayland primary-output synchronization.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@sourcery-ai

sourcery-ai Bot commented Aug 20, 2026

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

Reviewer's Guide

Guard against a null active session in XWayland primary-output sync to prevent compositor crashes when outputs are removed and the active session has already been reset.

Sequence diagram for guarded XWayland primary-output sync

sequenceDiagram
    participant Compositor
    participant SessionManager
    participant ActiveSession
    participant XWayland

    Compositor->>SessionManager: syncActiveSessionXWaylandPrimaryOutput()
    SessionManager->>SessionManager: primaryOutput check
    SessionManager->>ActiveSession: m_activeSession.lock()
    alt session is null
        SessionManager-->>Compositor: return (skip XWayland sync)
    else session is valid
        SessionManager->>XWayland: session.xwayland()
        XWayland->>XWayland: xcbConnection()
        XWayland->>XWayland: xcbScreen()
        SessionManager-->>Compositor: XWayland primary output synced
    end
Loading

File-Level Changes

Change Details Files
Add a null-check for the locked active session before using it in XWayland primary-output synchronization to prevent crashes.
  • Lock m_activeSession into a local variable before use instead of calling activeSession().lock() inline
  • Return early if the locked active session is null
  • Use the locally locked session pointer to access xwayland() instead of dereferencing a potentially null session
src/session/session.cpp

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

@glyvut
glyvut force-pushed the fix/xway-sync-null-active-session branch from 9c65767 to 2aa37e2 Compare August 20, 2026 09:40
@glyvut
glyvut marked this pull request as ready for review August 20, 2026 10:52

@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 ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: glyvut, zccrs

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

Check the weak_ptr lock result before dereferencing the active session.
When an output is removed, primaryOutputChanged is delivered
synchronously; if the active session was already reset (e.g. after a
logind session was removed), calling ->xwayland() on the null session
crashes the compositor.

输出移除时同步触发primaryOutputChanged,若活动会话已被重置,
对空指针调用->xwayland()会导致合成器崩溃,增加空指针守卫。

PMS: BUG-374551
Log: 修复输出移除(切 tty)时活动会话为空导致的崩溃
@glyvut
glyvut force-pushed the fix/xway-sync-null-active-session branch from 2aa37e2 to 4d40d89 Compare August 21, 2026 01:01
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.

3 participants