Skip to content

Serialize Linux URLSession request paths to mitigate _MultiHandle race#134

Open
mattt wants to merge 6 commits intomainfrom
mattt/gate-linux-urlsession
Open

Serialize Linux URLSession request paths to mitigate _MultiHandle race#134
mattt wants to merge 6 commits intomainfrom
mattt/gate-linux-urlsession

Conversation

@mattt
Copy link
Owner

@mattt mattt commented Feb 19, 2026

Resolves #127
Alternative to / complement of #128

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a critical use-after-free crash on Linux caused by a thread-safety bug in swift-corelibs-foundation's URLSession._MultiHandle. The fix introduces a serialization gate (LinuxURLSessionRequestGate) that ensures only one URLSession request executes at a time on Linux, mitigating concurrent access to the problematic _MultiHandle singleton.

Changes:

  • Adds LinuxURLSessionRequestGate actor to serialize URLSession operations on Linux
  • Wraps all data(for:) and streaming calls with the gate's lock on Linux platforms
  • Maintains separate code paths for Linux and non-Linux platforms using conditional compilation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Use-after-free crash on Linux: URLSession._MultiHandle thread-safety bug

1 participant

Comments