Skip to content

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

@al45tair al45tair requested a review from ktoso as a code owner June 27, 2025 10:10
@al45tair al45tair requested a review from mikeash June 27, 2025 10:10
@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.

Nice catch Lgtm

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
Copy link
Contributor Author

Just updated it to check leeway as well (which I noticed while trying to cherry pick to 6.2), since I think Dispatch may internally add these together, which could also cause trouble. Much less likely to sleep with negative leeway though.

@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

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

It would be better if a negative sleep caused execution to resume before the sleep call, but I suppose this will do for now.

@al45tair al45tair merged commit f2c820a into swiftlang:main Jun 30, 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.

3 participants