Skip to content

fix: flaky test due to overflow ub#462

Merged
poor-circle merged 1 commit intoalibaba:mainfrom
c8ef:ub
Mar 17, 2026
Merged

fix: flaky test due to overflow ub#462
poor-circle merged 1 commit intoalibaba:mainfrom
c8ef:ub

Conversation

@c8ef
Copy link
Copy Markdown
Collaborator

@c8ef c8ef commented Mar 17, 2026

Why

Fixes #461.

The duration cast here with max seconds is UB.

Lazy<void> sleep(Executor* ex, std::chrono::duration<Rep, Period> dur,
uint64_t schedule_hint) {
auto slot = co_await CurrentSlot{};
co_await ex->after(std::chrono::duration_cast<Executor::Duration>(dur),
schedule_hint, slot);
}

Proof: https://godbolt.org/z/v878q1Yjf

What is changing

Change to a big enough value without overflow.

Example

@c8ef
Copy link
Copy Markdown
Collaborator Author

c8ef commented Mar 17, 2026

cc @ChuanqiXu9 @poor-circle

@poor-circle
Copy link
Copy Markdown
Collaborator

Thanks! This problem worry me a long time.

@poor-circle
Copy link
Copy Markdown
Collaborator

LGTM

@poor-circle poor-circle merged commit 683ae86 into alibaba:main Mar 17, 2026
16 checks passed
@c8ef c8ef deleted the ub branch March 17, 2026 13:11
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.

Flaky test: FutureAwaiterTest.testWithFutureCancel

2 participants