Skip to content

[Concurrency] Prevent negative sleeps from sleeping forever. #82564

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

Open
wants to merge 1 commit into
base: release/6.2
Choose a base branch
from

Conversation

al45tair
Copy link
Contributor

Requests to sleep until a negative timestamp would result in sleeping until UINT64_MAX nanoseconds from the start of the relevant clock, which is about 585 years.

rdar://154346018

Requests to sleep until a negative timestamp would result in sleeping
until `UINT64_MAX` nanoseconds from the start of the relevant clock,
which is about 585 years.

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

Explanation: It's possible to pass a negative time to the Dispatch executor, and if you do that then you may end up trying to sleep for up to 585 years, which is effectively forever.
Risk: Low. It's a very small change.
Original PR: #82563
Reviewed by: @ktoso
Resolves: rdar://154346018
Tests: There is a test that tries to do negative sleeps. I'm not sure why it didn't catch this previously but it definitely was picking it up in my most recent Concurrency branch (#82456), and I think it's a good bet that this is the thing causing occasional inexplicable hangs during PR testing.

@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair
Copy link
Contributor Author

@swift-ci Please test macOS platform

1 similar comment
@al45tair
Copy link
Contributor Author

al45tair commented Jul 1, 2025

@swift-ci Please test macOS platform

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