{"record":{"id":"49c98f4de6bec451","repo":"nautechsystems/nautilus_trader","slug":"snapshot-interval-exceeds-u64","errorCode":null,"errorMessage":"Snapshot interval exceeds u64","messagePattern":"Snapshot interval exceeds u64","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/data/src/engine/mod.rs","lineNumber":4409,"sourceCode":"            if let Some(snapshotter) = self.book_snapshotters.remove(&interval_ms) {\n                let timer_name = snapshotter.timer_name;\n                let mut clock = self.clock.borrow_mut();\n                if clock.timer_exists(&timer_name) {\n                    clock.cancel_timer(&timer_name);\n                }\n            }\n        }\n\n        BookSnapshotUnsubscribeResult::Removed\n    }\n\n    fn schedule_book_snapshotter(\n        &mut self,\n        interval_ms: NonZeroUsize,\n        snapshot_infos: BookSnapshotInfos,\n    ) {\n        let interval_ms_u64 =\n            u64::try_from(interval_ms.get()).expect(\"Snapshot interval exceeds u64\");\n        let interval_ns = DurationNanos::from_millis(interval_ms_u64);\n        let now_ns = self.clock.borrow().timestamp_ns();\n        let start_time_ns = now_ns\n            .floor(interval_ns)\n            .checked_add(interval_ns)\n            .expect(\"Book snapshot timer start exceeds UnixNanos range\");\n\n        let snapshotter = Rc::new(BookSnapshotter::new(\n            interval_ms,\n            snapshot_infos,\n            self.cache.clone(),\n        ));\n        let timer_name = snapshotter.timer_name;\n        let snapshotter_callback = snapshotter.clone();\n        let callback_fn: Rc<dyn Fn(TimeEvent)> =\n            Rc::new(move |event| snapshotter_callback.snapshot(event));\n        let callback = TimeEventCallback::from(callback_fn);\n","sourceCodeStart":4391,"sourceCodeEnd":4427,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/data/src/engine/mod.rs#L4391-L4427","documentation":"`DataEngine::schedule_book_snapshotter` converts the snapshot interval (NonZeroUsize milliseconds) to u64 and `.expect`s the conversion succeeds, then derives a nanosecond interval. The try_from only fails on platforms where usize is wider than u64 (128-bit usize), which the library treats as an unsupported configuration.","triggerScenarios":"Running on a target where `usize` exceeds 64 bits and passing a snapshot interval that doesn't fit in u64; practically unreachable on 64-bit platforms but armed as an invariant guard.","commonSituations":"Exotic/embedded or non-standard Rust targets with oversized usize; defensive check hit during fuzzing or platform porting work.","solutions":["Build for a standard 64-bit target (x86_64/aarch64) where usize == u64 and this cannot fire","If porting to an unusual target, clamp/validate the interval to u64 range before scheduling","This indicates a platform/toolchain problem — verify the Rust target triple used for the build"],"exampleFix":"// before\nlet interval_ms_u64 = u64::try_from(interval_ms.get()).expect(\"Snapshot interval exceeds u64\");\n// after (caller-side guard, portable targets)\nlet ms = interval_ms.get();\nassert!(ms <= u64::MAX as usize, \"snapshot interval too large\");\nlet interval_ms_u64 = ms as u64;","handlingStrategy":"validation","validationCode":"// Rust: bound the interval before scheduling\nlet ms = interval_ms.get();\nassert!(ms <= u64::MAX as usize, \"snapshot interval exceeds u64\");","typeGuard":null,"tryCatchPattern":"let result = std::panic::catch_unwind(|| engine.schedule_book_snapshotter(interval_ms, infos));","preventionTips":["Build for standard 64-bit targets","Validate snapshot interval configuration at load time","Treat a hit here as a platform/toolchain misconfiguration"],"tags":["rust","panic","integer-overflow","platform"],"backgroundTag":"value-out-of-range","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}