{"record":{"id":"1f60050fb9520db5","repo":"firecracker-microvm/firecracker","slug":"bus-ranges-and-devices-out-of-sync","errorCode":null,"errorMessage":"Bus ranges and devices out of sync","messagePattern":"Bus ranges and devices out of sync","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/vmm/src/vstate/bus.rs","lineNumber":207,"sourceCode":"        addr: u64,\n        len: u64,\n        f: impl FnOnce(&mut dyn BusDevice, u64, u64) -> T,\n    ) -> Result<T, BusError> {\n        let access = BusRange::new(addr, len)?;\n\n        let devices = self.devices.read().unwrap();\n        let (base, slot) = {\n            let ranges = self.ranges.read().unwrap();\n            match ranges.range(..=access).next_back() {\n                // `range` query already guarantees `range.base() <= addr`.\n                Some((range, &slot)) if access.end() <= range.end() => (range.base(), slot),\n                _ => return Err(BusError::MissingAddressRange),\n            }\n        };\n\n        let device = devices\n            .get(slot)\n            .expect(\"Bus ranges and devices out of sync\");\n\n        let Some(device) = device.upgrade() else {\n            return Err(BusError::MissingAddressRange);\n        };\n\n        let mut locked = device.lock().unwrap();\n        let offset = addr - base;\n        Ok(f(&mut *locked, base, offset))\n    }\n\n    /// Relocate an existing device mapping from `old_base` to `new_base`.\n    /// Only the `ranges` lock is taken, not the `devices` lock.\n    pub fn move_range(&self, old_base: u64, new_base: u64, len: u64) -> Result<(), BusError> {\n        let old_range = BusRange::new(old_base, len)?;\n        let new_range = BusRange::new(new_base, len)?;\n\n        let mut ranges = self.ranges.write().unwrap();\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/firecracker-microvm/firecracker/blob/23b09b943fa3cd4a04004fe55724f0b5c2410f45/src/vmm/src/vstate/bus.rs#L189-L225","documentation":"Error \"Bus ranges and devices out of sync\" thrown in firecracker-microvm/firecracker.","triggerScenarios":"Thrown at src/vmm/src/vstate/bus.rs:201 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Keep the bus range list and device list updates in a single atomic operation so they cannot diverge.","Check the bus insert/remove logic for a path that updates one list without the other."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"23b09b943fa3cd4a04004fe55724f0b5c2410f45","analyzedAt":"2026-08-19T05:27:02.517Z","contentChangedAt":"2026-08-19T05:27:02.517Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}