fix: avoid to visit nullptr in binaryen#2943
Conversation
Module.getExpressionId will be used for nullptr ExpressionRef. It works because deref nullptr in binaryen's wasm is valid. Adding guard can enhance robustness
|
If we replace guard with assert, the compiler will crash during testing.
|
|
some background: I am trying to revert the relationship between AS and binaryen. it will create a new c++ program integrated binaryen in native as static lib and WASM runtime. Then it will load AS bootstrapped WASM to compile source code. |
|
Regarding that compiler crash, maybe we should find out where a null pointer is being passed, and see if that's intended? If it is intended, this change makes more sense. Regarding your testing with the AS compiler embedded within a C++ executable...I don't think you can upstream that, but it might be interesting to open-source if possible. It would definitely be cool to see how necessary the JS glue in binaryen.js is to AssemblyScript. |
open source is in progress. it should be finished in this year
It generated by |
CountBleck
left a comment
There was a problem hiding this comment.
LGTM. Looks like everyone else in compiler.ts/flow.ts does the same thing too!
Module.getExpressionId will be used for nullptr ExpressionRef. It works because deref nullptr in binaryen's wasm is valid.
check BinaryenExprRef non-null before.