jcode crashing
error:
thread 'main' (24656) panicked at /rustc/ac68faa20c58cbccd01ee7208bf3b6e93a7d7f96/library\std\src\time.rs:445:33:
overflow when subtracting duration from instant
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
running with bracktrace does not give more insights
Same crash — Windows 11, v0.32.0
thread 'main' (33196) panicked at /rustc/ac68faa20c58cbccd01ee7208bf3b6e93a7d7f96/library\std\src\time.rs:445:33:
overflow when subtracting duration from instant
Additional context from session log — crash happens during bash tool execution, captured in SESSION_PERSISTENCE:
status="Crashed { message: Some(\"Panic: panicked at /rustc/ac68faa20c58cbccd01ee7208bf3b6e93a7d7f96/library\std\src\time.rs:445:33:\noverflow when subtracting duration from instant\") }"
Sequence in log:
- Tool
bashstarts executing - Crash fires mid-execution
- Session marked
Crashedin persistence cleanup timed out waiting for agent lock (stuck task)— agent lock never released
Environment: Windows 11 Pro 22H2, 16-core CPU, jcode v0.32.0 (f31edd04)
Suspected cause: Instant::elapsed() panics when Windows QueryPerformanceCounter returns a non-monotonic value across CPU cores. RUST_BACKTRACE=1 gives no extra info (confirmed by #424 author too).
Update on my previous comment — found likely trigger:
The crash started after updating NVIDIA drivers + system reboot. Before the driver update, jcode ran stable for hours (including long sessions). After the reboot it crashes consistently on bash tool execution.
NVIDIA driver updates can change the Windows QueryPerformanceCounter source (HPET → TSC or vice versa). A QPC source change post-reboot can produce non-monotonic values across threads, which causes Rust's Instant::duration_since to panic when it receives an earlier instant than expected.
This would explain why the crash is not constant from launch but triggers specifically during tool execution (multiple threads measuring elapsed time concurrently).
Workaround attempted: start /AFFINITY 1 (pin to single core) — did not fix it, likely because the jcode server process runs separately and was unaffected.
Possible fix direction: replace duration_since calls with checked_duration_since and handle the None case gracefully instead of panicking.
Fixed in 1bd3c352. Root cause confirmed: Instant::now() - Duration::from_secs(3600) in the TUI info-widget cache invalidation. Instant counts from boot, so on a machine booted less than an hour ago the subtraction underflows and panics. That invalidation runs right after every bash/edit/write tool, which matches the 'crashes during bash tool execution' evidence exactly, and explains why it started after your driver update + reboot (fresh boot = small monotonic clock value) and settles down after an hour of uptime.
The fix adds a saturating backdated_now() helper used by all cache backdate sites. Lands in the next release. Until then, the workaround is simply uptime > 1 hour.
Released in v0.34.0. Run jcode update to get it.