Skip to content

Fix race condition and potential use-after-free on system distro & init port access - #41762

Merged
Blue (OneBlue) merged 2 commits into
masterfrom
user/oneblue/fix-distro-race
Oct 2, 2026
Merged

Blue (OneBlue) merged 2 commits into
masterfrom
user/oneblue/fix-distro-race

Conversation

@OneBlue

Copy link
Copy Markdown
Collaborator

Summary of the Pull Request

This change solves a synchronization issue between a thread accessing a running instance (via CreateLxProcess() for instance) and a thread terminating an instance.

std::shared_ptr isn't actually safe to read & write to at the time, so accesses to the system distro are wrapped in an std::atomic, and m_initChannel is now protected under m_lock

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Copilot AI balanced review requested due to automatic review settings October 1, 2026 18:25
@OneBlue
Blue (OneBlue) requested a review from a team as a code owner October 1, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The synchronization changes consistently address the identified shared-pointer races without introducing unresolved issues.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes concurrent access to WSL instance resources during termination.

Changes:

  • Makes system-distro ownership atomic and uses stable local references.
  • Synchronizes init-port retrieval with instance shutdown.
File Description
WslCoreInstance.h Defines atomic system-distro ownership.
WslCoreInstance.cpp Safely loads, clears, and retrieves shared resources.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@OneBlue
Blue (OneBlue) merged commit ee69aa7 into master Oct 2, 2026
11 checks passed
@OneBlue
Blue (OneBlue) deleted the user/oneblue/fix-distro-race branch October 2, 2026 00:16
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