Enabling SAFE_HEAP leads to wasm-validator errors
When setting the -sSAFE_HEAP=1 flag, I end up getting dozens of errors like the following:
[wasm-validator error in function cv::hal::cpu_baseline::\28anonymous\20namespace\29::RGB2HSV_b::TablesSingleton::getInstance\28\29] unexpected false: call target must exist, on
(call $SAFE_HEAP_LOAD_i32_1_U_A
(local.get $2)
(i32.const 0)
)
Mostly in the cv namespace (we use OpenCV), mostly SAFE_HEAP_LOAD_i32_1_U_A, but there is also some stuff from the libc++ (e.g. long\20long\20std::__2::__cxx_atomic_load\5babi:v160004\5d<long\20long>\28std::__2::__cxx_atomic_base_impl<long\20long>\20const*\2c\20std::__2::memory_order\29) and with other functions, like SAFE_HEAP_STORE_i64_8_A or SAFE_HEAP_LOAD_i64_8_A.
Is there any way to get around those errors ?
That looks like a serious and unknown bug, @cmourglia . Can you provide a testcase so we can investigate? I am afraid that error by itself isn't enough to know what is going wrong in your case.
I kinda hoped it was something known (like a bad interaction between two flags or something), but I'll see what I can do. We are using our own conan recipes plus a a big chunky list of cmake files, I'll see if I can isolate the issue and reproduce it, with public recipes and a repro case, but that might be tricky and take time 😬