Skip to content

Conversation

@plemarquand
Copy link
Contributor

@plemarquand plemarquand commented Nov 10, 2025

runtimeLibraryPaths, swiftCompilerVersion and targetInfo were all marked as lazy on the UserToolchain class which could lead to race conditions if callers on multiple threads attempted to initialize them simultaneously.

Use a ThreadSafeBox to guard access while initialization occurs, preventing crashes.

@plemarquand
Copy link
Contributor Author

@swift-ci please test

@plemarquand
Copy link
Contributor Author

@swift-ci please test

`runtimeLibraryPaths`, `swiftCompilerVersion` and `targetInfo` were all
marked as lazy on the UserToolchain class which could lead to race
conditions if callers on multiple threads attempted to initialize them
simultaneously.

Use an `NSRecursiveLock` to guard access while initialization occurs,
preventing crashes.
@plemarquand plemarquand force-pushed the thread-safe-lazy-usertoolchain branch from 6c9b43e to b3f0ac6 Compare November 11, 2025 13:57
@plemarquand
Copy link
Contributor Author

@swift-ci test

@plemarquand
Copy link
Contributor Author

@swift-ci test windows

@plemarquand
Copy link
Contributor Author

@swift-ci please test linux

@plemarquand plemarquand merged commit 9057cae into swiftlang:main Nov 12, 2025
7 checks passed
@plemarquand plemarquand deleted the thread-safe-lazy-usertoolchain branch November 12, 2025 13:45
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