Skip to content

fix(ic-cdk-timers): exponential backoff when cycles too low to schedule timer#709

Open
Rachit2323 wants to merge 5 commits intodfinity:mainfrom
Rachit2323:fix/timer-low-cycles-backoff
Open

fix(ic-cdk-timers): exponential backoff when cycles too low to schedule timer#709
Rachit2323 wants to merge 5 commits intodfinity:mainfrom
Rachit2323:fix/timer-low-cycles-backoff

Conversation

@Rachit2323
Copy link
Copy Markdown

Fixes #706

Rachit2323 and others added 2 commits April 17, 2026 03:49
- StableIO::seek with SeekFrom::End/SeekFrom::Current used unchecked
  `as i64`/`as u64` casts that silently overflow for stable memories
  > ~9.2 PB or when seeking past i64/u64 boundaries, producing corrupt
  seek positions and potential silent data corruption.
- StableIO::write computed `self.offset + buf.len() as u64` without
  overflow protection; now returns OutOfBounds on overflow.
- global_timer instruction limit guard used `insn_count * 3` which
  overflows u64 if insn_count > u64::MAX / 3, causing the guard to
  under-count and the canister to exceed its instruction limit.
- Removed stale TODO comment in ic-cdk-bindgen (type-selector config
  is already implemented); added cargo:warning when emit_bindgen
  returns unused types so users are notified via build output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…le timer

When liquid_cycles < cost, the timer was returned unchanged with its original
timestamp (already in the past), causing ic0::global_timer_set to receive a
past timestamp and fire canister_global_timer immediately every round.

Fix: update timer.time = now + backoff before returning, with exponential
backoff 5s -> 10s -> 20s -> 40s -> 60s capped. Backoff resets to 0 when
the timer runs successfully.

Fixes dfinity#706
@Rachit2323 Rachit2323 requested a review from a team as a code owner April 17, 2026 09:59
@cla-idx-bot
Copy link
Copy Markdown

cla-idx-bot Bot commented Apr 17, 2026

Dear @Rachit2323,

In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA.

If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged.

— The DFINITY Foundation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite loop of "unable to schedule timer" when cycles run low

1 participant