{"record":{"id":"b10ef428bc81d7c1","repo":"swc-project/swc","slug":"free-list-points-to-occupied-slot","errorCode":null,"errorMessage":"free list points to occupied slot","messagePattern":"free list points to occupied slot","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_arena/src/lib.rs","lineNumber":217,"sourceCode":"    /// Inserts a value and returns its id.\n    ///\n    /// Reuses freed slots through an internal free list.\n    ///\n    /// # Panics\n    ///\n    /// Panics if the arena has reached its maximum number of slots.\n    #[inline]\n    pub fn insert(&mut self, value: T) -> Id<T> {\n        if self.free_head != INVALID_INDEX {\n            let index = self.free_head as usize;\n            let slot = self\n                .slots\n                .get_mut(index)\n                .expect(\"free list index should be valid\");\n\n            let next = match &slot.entry {\n                SlotEntry::Vacant { next } => *next,\n                SlotEntry::Occupied(_) => unreachable!(\"free list points to occupied slot\"),\n            };\n\n            self.free_head = next;\n            self.len += 1;\n            slot.entry = SlotEntry::Occupied(value);\n\n            return Id::from_parts(index as u32, slot.generation);\n        }\n\n        assert!(\n            self.slots.len() < MAX_SLOTS,\n            \"arena reached maximum slot count\"\n        );\n\n        let index = self.slots.len() as u32;\n        self.slots.push(Slot {\n            generation: INITIAL_GENERATION,\n            entry: SlotEntry::Occupied(value),","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_arena/src/lib.rs#L199-L235","documentation":"An internal consistency panic in `insert` of the slot-arena (swc_arena lib.rs:217). When reusing a freed slot from the internal free list, the code expects the slot's entry to still be Vacant; if it finds the slot occupied (entry no longer Vacant), the free list has been corrupted — typically by use-after-free of an Id, double-free, or unsafe aliasing of arena mutations. The corrupted free-list state, not user payload data, is what trips it.","triggerScenarios":"Thrown at crates/swc_arena/src/lib.rs:217 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Audit for use-after-free: ensure Ids are not used to mutate the arena after the slot was freed","Check for double-frees of the same Id","Add a debug assertion when freeing that the slot is still Vacant before linking it into the free list, to catch corruption earlier"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}