{"record":{"id":"ff8b8299b3b49b4d","repo":"zed-industries/zed","slug":"detected-over-release-of-a-handle","errorCode":null,"errorMessage":"detected over-release of a handle.","messagePattern":"detected over-release of a handle\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui/src/app/entity_map.rs","lineNumber":346,"sourceCode":"            handle_id: self\n                .entity_map\n                .upgrade()\n                .unwrap()\n                .write()\n                .leak_detector\n                .handle_created(self.entity_id, None),\n        }\n    }\n}\n\nimpl Drop for AnyEntity {\n    fn drop(&mut self) {\n        if let Some(entity_map) = self.entity_map.upgrade() {\n            let entity_map = entity_map.upgradable_read();\n            let count = entity_map\n                .counts\n                .get(self.entity_id)\n                .expect(\"detected over-release of a handle.\");\n            let prev_count = count.fetch_sub(1, SeqCst);\n            assert_ne!(prev_count, 0, \"Detected over-release of a entity.\");\n            if prev_count == 1 {\n                // We were the last reference to this entity, so we can remove it.\n                let mut entity_map = RwLockUpgradableReadGuard::upgrade(entity_map);\n                entity_map.dropped_entity_ids.push(self.entity_id);\n            }\n        }\n\n        #[cfg(any(test, feature = \"leak-detection\"))]\n        if let Some(entity_map) = self.entity_map.upgrade() {\n            entity_map\n                .write()\n                .leak_detector\n                .handle_released(self.entity_id, self.handle_id)\n        }\n    }\n}","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/gpui/src/app/entity_map.rs#L328-L364","documentation":"AnyEntity::drop decrements the entity's reference count; the expect fires when there is no count entry for this entity_id, i.e. the handle is being dropped more times than it was cloned or after the entity was already released. This detects double-drop / over-release of GPUI entity handles.","triggerScenarios":"Thrown at crates/gpui/src/app/entity_map.rs:346 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Search for manual drops or unsafe code causing a duplicate Drop of the same handle","Check for a clone/drop imbalance, e.g. transmuted or forgotten clones","Enable the leak detector output to trace handle creation and drops"],"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"}