The codegen test added in #1378 verifies the generated JS contains the null check, but it doesn't exercise the actual failure path. A behavioral test would be more robust as it would catch regressions even if the codegen is refactored.
To reproduce the crash at runtime, a test component needs to call an import during realloc. One way to do this would be a test component in crates/test-components that uses a custom allocator which calls an import on every allocation, then have the test call two string-accepting exports back to back. The second export's _utf8AllocateAndEncode would fire the import while CURRENT_TASK_META is null from the first export's cleanup.
This would also serve as a general regression test for any situation where imports fire outside of an active export task, not just the allocator case, but also components with initialization logic that calls imports before any export has been invoked.
The codegen test added in #1378 verifies the generated JS contains the null check, but it doesn't exercise the actual failure path. A behavioral test would be more robust as it would catch regressions even if the codegen is refactored.
To reproduce the crash at runtime, a test component needs to call an import during
realloc. One way to do this would be a test component incrates/test-componentsthat uses a custom allocator which calls an import on every allocation, then have the test call two string-accepting exports back to back. The second export's_utf8AllocateAndEncodewould fire the import whileCURRENT_TASK_METAisnullfrom the first export's cleanup.This would also serve as a general regression test for any situation where imports fire outside of an active export task, not just the allocator case, but also components with initialization logic that calls imports before any export has been invoked.