swc-project/swc · error
free list points to occupied slot
Error message
free list points to occupied slot
What it means
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.
Source
Thrown at crates/swc_arena/src/lib.rs:217
/// Inserts a value and returns its id.
///
/// Reuses freed slots through an internal free list.
///
/// # Panics
///
/// Panics if the arena has reached its maximum number of slots.
#[inline]
pub fn insert(&mut self, value: T) -> Id<T> {
if self.free_head != INVALID_INDEX {
let index = self.free_head as usize;
let slot = self
.slots
.get_mut(index)
.expect("free list index should be valid");
let next = match &slot.entry {
SlotEntry::Vacant { next } => *next,
SlotEntry::Occupied(_) => unreachable!("free list points to occupied slot"),
};
self.free_head = next;
self.len += 1;
slot.entry = SlotEntry::Occupied(value);
return Id::from_parts(index as u32, slot.generation);
}
assert!(
self.slots.len() < MAX_SLOTS,
"arena reached maximum slot count"
);
let index = self.slots.len() as u32;
self.slots.push(Slot {
generation: INITIAL_GENERATION,
entry: SlotEntry::Occupied(value),View on GitHub (pinned to 5176682b65)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_arena/src/lib.rs:217 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/b10ef428bc81d7c1.
Report an issue: GitHub.