- 
                Notifications
    You must be signed in to change notification settings 
- Fork 728
Description
ref.null 0 is valid under the GC specification but invalid under the current specification(only allow externref and funcref). This means a Wasm runtime should report a validation error when loading a Wasm module that contains ref.null 0 if GC is not enabled. The same applies to wamrc.
But the latest version of wamrc will not report a validation error. This is because:
- By design, unlike iwasm, wamrc is a full-feature component that uses execution switchers (command line options) instead of compilation flags to configure all supported features. So GC is always-on in wamrc.
- wamrc will validate the ref.nullopcode in WebAssembly modules under the GC specification by always enabling the compilation flagWASM_ENABLE_GC. Although there is a--enable-gcoption in wamrc's command line options which is able to disable gc during execution, this option is not passed to the WebAssembly loader and is only used during and after AOT loading.
- There should be an additional opcode validator in code generation (compilation) after WebAssembly loading in wamrc. However, in a specific case(WAMR JIT mode incorrectly outputs type_mismatch #4480), br 0will skip all following opcodes, includingref.null 0.
In my opinion, there are still three options available to handle this ref.null 0.
a. pass command line options of wamrc to wasm loader. like an extra parameter in wasm_runtime_load().
b. add opcode validation in aot_validate_wasm()
c. in CMakeLists.txt of wamrc, make WASM_ENABLE_GC configurable.
From my perspective, options a. and b. are too burdensome since ref.null is the only opcode that currently requires extra attention. I prefer to use option c.