Fix double-free of cached WASM module in fizzy vm_manager - #7
Open
pgarciagon wants to merge 1 commit into
Open
Conversation
fizzy_vm_backend::run() caches a parsed module in a module_guard (frees it via fizzy_free_module), then passes the same pointer to fizzy_resolve_instantiate, which per fizzy's API takes ownership of the module and frees it via fizzy_free_instance. The same FizzyModule is freed twice. A double free is UB that a strict allocator crashes on (macOS 26 SDK: EXC_BAD_ACCESS in fizzy::Module::~Module during module_cache teardown) while older allocators tolerate it silently. Instantiate a fizzy_clone_module() copy so the FizzyInstance owns its own module and the cache keeps the original, and make module_guard non-copyable/non-movable. Verified in the koinos-chain twin (koinos/koinos-chain#862) with an AddressSanitizer build: zero ASan errors, full suite green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Teleno vendors the same koinos
vm_manageras koinos-chain and carries the same double-free.fizzy_vm_backend::run()caches a parsed WASM module in amodule_guard(frees it viafizzy_free_module), then passes the same pointer tofizzy_resolve_instantiate, which per fizzy's API takes ownership of the module and frees it viafizzy_free_instance. The sameFizzyModuleis freed twice.A double free is UB that surfaces only under a strict allocator: it crashes deterministically on the macOS 26 SDK (
EXC_BAD_ACCESSinfizzy::Module::~Moduleduringmodule_cacheteardown) and is tolerated silently on older allocators.Fix: instantiate a
fizzy_clone_module()copy so the instance owns its own module and the cache keeps the original; makemodule_guardnon-copyable/non-movable.Twin of koinos/koinos-chain#862, where it was root-caused with AddressSanitizer (zero ASan errors after the fix, full suite green).