Skip to content
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

[WIP] Task.sleep(.max) awakes immediately #69118

Closed
wants to merge 3 commits into from

Conversation

ktoso
Copy link
Member

@ktoso ktoso commented Oct 11, 2023

For now reproducing the issue and need to figure out why dispatch behaves like this and what we want to do about it.

@ktoso ktoso requested a review from kavon as a code owner October 11, 2023 06:15
@ktoso ktoso requested a review from phausler October 11, 2023 08:39
fprintf(stderr, "[%s:%d](%s) monotonic time mask, | mask: %llu\n", __FILE_NAME__, __LINE__, __FUNCTION__, DISPATCH_UP_OR_MONOTONIC_TIME_MASK);
fprintf(stderr, "[%s:%d](%s) monotonic time mask, value | mask: %llu\n", __FILE_NAME__, __LINE__, __FUNCTION__, value | DISPATCH_UP_OR_MONOTONIC_TIME_MASK);
// return value | DISPATCH_UP_OR_MONOTONIC_TIME_MASK;
return value; // FIXME: sure this "works" but that's not the right fix I suppose...
Copy link
Member Author

Choose a reason for hiding this comment

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

So this "works" but seems quite wrong... I was poking around in the withDeadline impl here but tbh not entirely sure where the issue resides... might be best for you @phausler to have a look at the swift_task_enqueueGlobalWithDeadlineImpl and make it pass the added tests now

@ktoso ktoso marked this pull request as draft October 11, 2023 09:03
let t = Task.detached {
print("Run infinite sleep")
try? await Task.sleep(for: .nanoseconds(UInt64.max))
print("Infinite sleep done (cancelled: \(Task.isCancelled)) @ \(#function)")
Copy link
Member

@phausler phausler Oct 11, 2023

Choose a reason for hiding this comment

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

I think we should adjust it on the Swift side (at the point of concrete clocks) to clamp the value there; because testing it like this gets a duration of 709551615000000000 seconds, 18446744073 attoseconds

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm so just cap it at Int64.max on the swift side perhaps...

Copy link
Member

Choose a reason for hiding this comment

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

yea, that seems reasonable to me (or cap and loop)

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.

None yet

2 participants