-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Thanks to @stupendoussuperpowers for spotting this bug.
We discovered a panic [3i|_add_global_grate] attempt to overwrite existing grate entry for grateid that occurs when calling register_handler multiple times inside the same grate to register different handlers. The root cause is that we were registering the grate context multiple times, rather than only updating the handler table.
During the previous refactor of the grate execution flow, I changed the context-registration logic so that the grate context would be sent to 3i every time register_handler is invoked. This inadvertently caused repeated context registrations for the same grate.
My current fix is to add a cageid–based check inside 3i so that a grate context is only registered once per cage.
Since this issue only manifests when the entire lind-wasm is running, it cannot be fully captured by existing 3i unit tests, even though we have tests inside 3i that appear to cover this scenario. As part of the fix PR, we will also need to add a dedicated test case in the unit-test folder to ensure this behavior is properly validated going forward.