Serialize Linux URLSession request paths to mitigate _MultiHandle race#134
Serialize Linux URLSession request paths to mitigate _MultiHandle race#134
URLSession request paths to mitigate _MultiHandle race#134Conversation
There was a problem hiding this comment.
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
LinuxURLSessionRequestGateactor 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.
Sources/AnyLanguageModel/Extensions/URLSession+Extensions.swift
Outdated
Show resolved
Hide resolved
Sources/AnyLanguageModel/Extensions/URLSession+Extensions.swift
Outdated
Show resolved
Hide resolved
Sources/AnyLanguageModel/Extensions/URLSession+Extensions.swift
Outdated
Show resolved
Hide resolved
Sources/AnyLanguageModel/Extensions/URLSession+Extensions.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
Sources/AnyLanguageModel/Extensions/URLSession+Extensions.swift
Outdated
Show resolved
Hide resolved
Sources/AnyLanguageModel/Extensions/URLSession+Extensions.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
Resolves #127
Alternative to / complement of #128