{"record":{"id":"e0a3b1bfd7ede108","repo":"bevyengine/bevy","slug":"attempted-to-free-an-already-freed-binding","errorCode":null,"errorMessage":"Attempted to free an already-freed binding","messagePattern":"Attempted to free an already-freed binding","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_render/src/material_bind_groups.rs","lineNumber":2160,"sourceCode":"                debug_assert!(self.bindings[slot as usize].is_none());\n                self.bindings[slot as usize] = Some(MaterialBindlessBinding::new(resource));\n\n                self.len += 1;\n                slot\n            }\n        }\n    }\n\n    /// Removes a reference to an object from the slot.\n    ///\n    /// If the reference count dropped to 0 and the object was freed, this\n    /// method returns true. If the object was still referenced after removing\n    /// it, returns false.\n    fn remove(&mut self, slot: u32) -> bool {\n        let maybe_binding = &mut self.bindings[slot as usize];\n        let binding = maybe_binding\n            .as_mut()\n            .expect(\"Attempted to free an already-freed binding\");\n\n        binding.ref_count -= 1;\n        if binding.ref_count != 0 {\n            return false;\n        }\n\n        let binding_resource_id = binding.resource.binding_resource_id(self.resource_type);\n        self.resource_to_slot.remove(&binding_resource_id);\n\n        *maybe_binding = None;\n        self.free_slots.push(slot);\n        self.len -= 1;\n        true\n    }\n}\n\nimpl<R> MaterialBindlessBinding<R>\nwhere","sourceCodeStart":2142,"sourceCodeEnd":2178,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_render/src/material_bind_groups.rs#L2142-L2178","documentation":"Panic in MaterialBindlessSlotMap::remove: the binding at the given slot is None, i.e. the slot was already freed (or never allocated) when a reference was removed. Indicates double-free of a bindless slot in material binding bookkeeping.","triggerScenarios":"Thrown at crates/bevy_render/src/material_bind_groups.rs:2160 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report as a Bevy engine bug with a reproducing project","Avoid rapid material/resource destruction sequences that trigger the double free"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}