From dede07748a789079c0fd53dd08037ed1568651ea Mon Sep 17 00:00:00 2001 From: faumaray Date: Wed, 24 Jun 2026 21:24:03 +0300 Subject: [PATCH] Fix hot-reload ABI break: move reloadConfig() to end of ICoreInterface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ICoreInterface is the vtable ABI contract between the already-loaded Plugin and a freshly hot-reloaded Core. reloadConfig() was added mid-interface (after getConfigJson), which shifted every later vtable slot — so the still-running Plugin's calls to saveState/restoreState/getStateFormatVersion/onPluginEvent dispatched to the wrong methods on the new Core. Symptom: state restore read a garbage version (2303262719), threw basic_string::_M_create, and left the Core uninitialized (onPluginEvent ignored, initialized=false). Move reloadConfig() to the very end of the interface (append-only) so all pre-existing slots keep their indices. Add a comment documenting the rule. Co-Authored-By: Claude Opus 4.8 --- include/echoion/api/interfaces/CoreInterface.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/echoion/api/interfaces/CoreInterface.hpp b/include/echoion/api/interfaces/CoreInterface.hpp index db68a18..4bfb724 100644 --- a/include/echoion/api/interfaces/CoreInterface.hpp +++ b/include/echoion/api/interfaces/CoreInterface.hpp @@ -93,9 +93,6 @@ namespace Echoion::Api updateConfigJson(const std::string& configJson) = 0; [[nodiscard]] virtual Result getConfigJson() const = 0; - // Reload configuration from the config file on disk. - virtual Result reloadConfig() = 0; - // Hot reload - using serialization instead of HotReloadState // Returns opaque handle that Plugin just passes back [[nodiscard]] virtual Result prepareForHotReload() = 0; @@ -152,6 +149,15 @@ namespace Echoion::Api getConfigHandle() const = 0; virtual Result updateConfigFromHandle(AppConfigHandle config) = 0; + + // Reload configuration from the config file on disk. + // NOTE: append-only. ICoreInterface is the hot-reload ABI contract + // between the (already-loaded) Plugin and a freshly reloaded Core. + // Inserting/removing a virtual method anywhere above shifts every + // later vtable slot, so the old Plugin would call the wrong methods + // on the new Core (state-transfer corruption on hot reload). Only + // ever add new virtuals at the very end. + virtual Result reloadConfig() = 0; }; } // namespace Echoion::Api