Skip to content

[Concurrency] Fix null pointer dereference for task-to-thread model. #82204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

al45tair
Copy link
Contributor

In task-to-thread concurrency mode, _getMainExecutorAsSerialExecutor returns SerialExecutorRef::generic(), which is, give or take, NULL. Unfortunately we'd declared it as returning any SerialExecutor, rather than (any SerialExecutor)?, and then the getMainExecutor() function was calling asUnownedSerialExecutor() on it, which then crashes.

rdar://153152063

In task-to-thread concurrency mode, `_getMainExecutorAsSerialExecutor`
returns `SerialExecutorRef::generic()`, which is, give or take, NULL.
Unfortunately we'd declared it as returning `any SerialExecutor`,
rather than `(any SerialExecutor)?`, and then the `getMainExecutor()`
function was calling `asUnownedSerialExecutor()` on it, which then
crashes.

rdar://153152063
@al45tair al45tair requested a review from a team as a code owner June 12, 2025 10:57
@al45tair al45tair added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jun 12, 2025
@al45tair
Copy link
Contributor Author

Explanation: Fixes a null pointer dereference (caused by the combination of task-to-thread model concurrency and the shenanigans we get up to to avoid reference counting the executors).
Risk: Low. Fixes a bug.
Original PR: #82202
Reviewed by: @ktoso
Resolves: rdar://153152063
Tests: Task-to-thread-model doesn't appear to be tested at all, which is… unfortunate. I've tested the specific pattern we're using here separately in a test program to make sure it does what we expect.

@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair al45tair merged commit 5f48a7e into swiftlang:release/6.2 Jun 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants