Skip to content

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

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 12, 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 ktoso as a code owner June 12, 2025 10:44
@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Lgtm. Hope noone has adopted this api yet? (I'd assume so given the _)

@al45tair al45tair merged commit 7a359a5 into swiftlang:main Jun 12, 2025
3 checks passed
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