{"record":{"id":"8f7f4c1a00256aec","repo":"bevyengine/bevy","slug":"error-calling-hotpatched-system-run-a-full-rebuil-8f7f4c","errorCode":null,"errorMessage":"Error calling hotpatched system. Run a full rebuild","messagePattern":"Error calling hotpatched system\\. Run a full rebuild","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/system/function_system.rs","lineNumber":692,"sourceCode":"        let state = self.state.as_mut().expect(Self::ERROR_UNINITIALIZED);\n        assert_eq!(state.world_id, world.id(), \"Encountered a mismatched World. A System cannot be used with Worlds other than the one it was initialized with.\");\n        // SAFETY:\n        // - The above assert ensures the world matches.\n        // - All world accesses used by `F::Param` have been registered, so the caller\n        //   will ensure that there are no data access conflicts.\n        let params = unsafe {\n            F::Param::get_param(&mut state.param, &self.system_meta, world, change_tick)\n        }?;\n\n        #[cfg(feature = \"hotpatching\")]\n        let out = {\n            let mut hot_fn = subsecond::HotFn::current(<F as SystemParamFunction<Marker>>::run);\n            // SAFETY:\n            // - pointer used to call is from the current jump table\n            unsafe {\n                hot_fn\n                    .try_call_with_ptr(self.current_ptr, (&mut self.func, input, params))\n                    .expect(\"Error calling hotpatched system. Run a full rebuild\")\n            }\n        };\n        #[cfg(not(feature = \"hotpatching\"))]\n        let out = self.func.run(input, params);\n\n        self.system_meta.last_run = change_tick;\n        IntoResult::into_result(out)\n    }\n\n    #[cfg(feature = \"hotpatching\")]\n    #[inline]\n    fn refresh_hotpatch(&mut self) {\n        let new = subsecond::HotFn::current(<F as SystemParamFunction<Marker>>::run).ptr_address();\n        if new != self.current_ptr {\n            log::debug!(\"system {} hotpatched\", self.name());\n        }\n        self.current_ptr = new;\n    }","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/system/function_system.rs#L674-L710","documentation":"With the hotpatching feature, function systems are invoked through subsecond jump-table function pointers (HotFn::try_call_with_ptr). This expect fires when the stored current_ptr does not match the current jump table - i.e. a hot patch invalidated the pointer and refresh_hotpatch has not updated this system since. The panic message prescribes a full rebuild.","triggerScenarios":"Applying a subsecond hot patch and then running a system whose cached pointer went stale because the refresh did not reach it; systems cached outside schedules missing their refresh_hotpatch call after reload.","commonSituations":"Hot-reload workflows that patch while systems are mid-execution or paused; tooling that reloads in a different order than bevy expects; long-running sessions accumulating partial patches.","solutions":["Perform a full rebuild/restart so all jump tables and cached pointers are recreated.","Let systems live inside schedules so bevy's refresh path updates them on reload; call refresh_hotpatch manually on any system you cache outside a schedule.","If stale pointers recur for scheduled systems, capture the sequence (patch timing vs. run timing) and report it upstream."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Rebuild fully after hot patches instead of resuming on partially refreshed state.","Let systems live in schedules so refresh_hotpatch reaches them on reload.","If caching systems outside schedules, call refresh_hotpatch after every patch."],"tags":["bevy","ecs","hotpatching","subsecond","function-pointer","system"],"backgroundTag":"stale-pointer-after-hot-reload","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"}