Description
Instant::now() - ttl panics with overflow when subtracting duration when the monotonic clock has not yet elapsed ttl worth of time. This is a logic error, not a platform-specific bug.
Root cause
pool.rs computes let cutoff = Instant::now() - ttl. Rust's Instant - Duration calls checked_sub().expect() - it panics on underflow. The monotonic clock starts at boot on all platforms, so this panics whenever uptime < TTL (e.g. session_ttl_hours=48 on a machine with < 48h uptime).
Why was this never reported?
- Linux servers typically have uptimes of weeks/months, far exceeding the 48h default TTL
- The panic only triggers on the reaper tick (every ~60s), not at startup
- The bug is platform-agnostic - a freshly booted Linux machine would also panic
Expected behavior
The reaper should classify sessions as fresh (not idle) when the elapsed time cannot be computed, rather than panicking.
Reproduction
- Set
session_ttl_hours = 48 in openab config
- Boot any machine (Linux or Windows)
- Start openab before uptime reaches 48h
- Wait for first reaper tick (~60s)
- Observe panic:
overflow when subtracting duration from instant
Proposed fix
Replace Instant::now() - ttl with now.saturating_duration_since(last_active) > ttl. Returns Duration::ZERO on underflow instead of panicking.
Relevant code
crates/openab-core/src/acp/pool.rs - classify_idle function and reaper loop
Description
Instant::now() - ttlpanics withoverflow when subtracting durationwhen the monotonic clock has not yet elapsedttlworth of time. This is a logic error, not a platform-specific bug.Root cause
pool.rscomputeslet cutoff = Instant::now() - ttl. Rust'sInstant - Durationcallschecked_sub().expect()- it panics on underflow. The monotonic clock starts at boot on all platforms, so this panics whenever uptime < TTL (e.g.session_ttl_hours=48on a machine with < 48h uptime).Why was this never reported?
Expected behavior
The reaper should classify sessions as fresh (not idle) when the elapsed time cannot be computed, rather than panicking.
Reproduction
session_ttl_hours = 48in openab configoverflow when subtracting duration from instantProposed fix
Replace
Instant::now() - ttlwithnow.saturating_duration_since(last_active) > ttl. ReturnsDuration::ZEROon underflow instead of panicking.Relevant code
crates/openab-core/src/acp/pool.rs-classify_idlefunction and reaper loop