{"record":{"id":"fcc43e3aa10a59ac","repo":"zed-industries/zed","slug":"detected-over-release-of-a-entity","errorCode":null,"errorMessage":"detected over-release of a entity","messagePattern":"detected over-release of a entity","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui/src/app/entity_map.rs","lineNumber":318,"sourceCode":"        if TypeId::of::<T>() == self.entity_type {\n            Ok(Entity {\n                any_entity: self,\n                entity_type: PhantomData,\n            })\n        } else {\n            Err(self)\n        }\n    }\n}\n\nimpl Clone for AnyEntity {\n    fn clone(&self) -> Self {\n        if let Some(entity_map) = self.entity_map.upgrade() {\n            let entity_map = entity_map.read();\n            let count = entity_map\n                .counts\n                .get(self.entity_id)\n                .expect(\"detected over-release of a entity\");\n            let prev_count = count.fetch_add(1, SeqCst);\n            assert_ne!(prev_count, 0, \"Detected over-release of a entity.\");\n        }\n\n        Self {\n            entity_id: self.entity_id,\n            entity_type: self.entity_type,\n            entity_map: self.entity_map.clone(),\n            #[cfg(any(test, feature = \"leak-detection\"))]\n            handle_id: self\n                .entity_map\n                .upgrade()\n                .unwrap()\n                .write()\n                .leak_detector\n                .handle_created(self.entity_id, None),\n        }\n    }","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/gpui/src/app/entity_map.rs#L300-L336","documentation":"AnyEntity::clone increments the entity's reference count looked up by entity_id; the expect fires when the count entry is missing, meaning the entity was already fully released and the map slot cleared. Cloning a handle after its count hit zero means a handle outlived entity release — an over-release / use-after-release bug.","triggerScenarios":"Thrown at crates/gpui/src/app/entity_map.rs:318 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Audit code that clones an AnyEntity after the entity has been released","Look for handles stored beyond entity release (e.g. in globals or callbacks firing post-release)","Run with the leak detector enabled to find which handle was dropped twice"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}