WasmEdge: segfault when checkAccessBound
Description
I am trying to integrate WasmEdge into wasm-nginx-module. When I tried to use WasmEdge as the Wasm VM, I got a segfault:
(gdb) bt
#0 WasmEdge::AST::Limit::getMin (this=0x0) at /home/lzx/git/WasmEdge/include/ast/type.h:47
#1 0x00007fc0bf1d9fbd in WasmEdge::Runtime::Instance::MemoryInstance::checkAccessBound (this=0x0, Offset=92, Length=4)
at /home/lzx/git/WasmEdge/include/runtime/instance/memory.h:77
#2 0x00007fc0bf27ab5b in WasmEdge::Runtime::Instance::MemoryInstance::storeValue<unsigned int> (this=0x0, Value=@0x7ffd1e231908: 0, Offset=92, Length=4)
at /home/lzx/git/WasmEdge/include/runtime/instance/memory.h:311
#3 0x00007fc0bf25ddee in WasmEdge::Executor::Executor::runStoreOp<unsigned int> (this=0x1813930, MemInst=..., Instr=..., BitWidth=32)
at /home/lzx/git/WasmEdge/include/executor/engine/memory.ipp:60
#4 0x00007fc0bf250684 in WasmEdge::Executor::Executor::execute(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Instruction const*, WasmEdge::AST::Instruction const*)::$_0::operator()() const (this=0x7ffd1e233290) at /home/lzx/git/WasmEdge/lib/executor/engine/engine.cpp:242
#5 0x00007fc0bf24ec3a in WasmEdge::Executor::Executor::execute (this=0x1813930, StoreMgr=..., Start=0x304f950, End=0x304fa10)
at /home/lzx/git/WasmEdge/lib/executor/engine/engine.cpp:1606
#6 0x00007fc0bf24eed6 in WasmEdge::Executor::Executor::runFunction(WasmEdge::Runtime::StoreManager&, WasmEdge::Runtime::Instance::FunctionInstance const&, cxx20::span<WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::UnknownRef, WasmEdge::FuncRef, WasmEdge::ExternRef> const, 18446744073709551615ul>) (this=0x1813930, StoreMgr=..., Func=..., Params=...) at /home/lzx/git/WasmEdge/lib/executor/engine/engine.cpp:44
#7 0x00007fc0bf288a88 in WasmEdge::Executor::Executor::invoke(WasmEdge::Runtime::StoreManager&, unsigned int, cxx20::span<WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::UnknownRef, WasmEdge::FuncRef, WasmEdge::ExternRef> const, 18446744073709551615ul>, cxx20::span<WasmEdge::ValType const, 18446744073709551615ul>) (this=0x1813930, StoreMgr=..., FuncAddr=2766, Params=..., ParamTypes=...)
at /home/lzx/git/WasmEdge/lib/executor/executor.cpp:108
#8 0x00007fc0bf171c51 in WasmEdge_ExecutorInvoke::$_9::operator() (this=0x7ffd1e2338a0) at /home/lzx/git/WasmEdge/lib/api/wasmedge.cpp:1528
#9 0x00007fc0bf16af0f in (anonymous namespace)::wrap<WasmEdge_ExecutorInvoke::$_9, WasmEdge_ExecutorInvoke::$_10, WasmEdge_ExecutorContext, WasmEdge_StoreContext> (Proc=...,
Then=..., Cxts=0x1859ff0, Cxts=0x1859ff0) at /home/lzx/git/WasmEdge/lib/api/wasmedge.cpp:265
#10 0x00007fc0bf16a828 in WasmEdge_ExecutorInvoke (Cxt=0x1813930, StoreCxt=0x1859ff0, FuncName=..., Params=0x7ffd1e233b80, ParamLen=2, Returns=0x7ffd1e233b60, ReturnLen=1)
at /home/lzx/git/WasmEdge/lib/api/wasmedge.cpp:1506
#11 0x0000000000699c30 in ngx_wasm_wasmedge_call (data=0x3053ca0, name=0x72bd60 <proxy_on_configure>, has_result=true, param_type=3)
at /home/lzx/git/wasm-nginx-module/src/vm/wasmedge.c:325
#12 0x00000000006915db in ngx_http_wasm_on_configure (hw_plugin=0x23d97d0, conf=0x7fc0be967e20 "{\"http_status\": 401, \"percentage\": 0}", size=37)
at /home/lzx/git/wasm-nginx-module/src/http/ngx_http_wasm_module.c:422
The code can be found in https://github.com/api7/wasm-nginx-module/pull/93/files#diff-29a3e0c7bd2fd8b0d13dd0490a28522f81448eecc538703e39429410ee424ea8R260
I could send you the .wasm file if needed.
Environment
- Hardware Architecture: (e.g. x86_64 or aarch64) x86_64
- Operating system: (e.g. Ubuntu 20.04 or CentOS 7.6) Ubuntu 20.04
The following information is optional. Please provide them only if you have built from source.
- C++ Compiler version:
- CMake version:
- CMake flags: (e.g.
-DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_AOT_RUNTIME=ON) - Boost version:
Steps to Reproduce
Run the https://github.com/api7/wasm-nginx-module/blob/main/t/rust.t test with the code in https://github.com/api7/wasm-nginx-module/pull/93
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 25 (12 by maintainers)
Thanks a lot. I’ll try to add some log in WasmEdge to find out the reason. The WasmEdge 0.10.0 has breaking changes in C API. You can try to update if you want with the Guideline. Thanks.
Yes, the
got: ''means the Nginx crashed in the middle, so it doesn’t reply to any expected response.Congratulation, now we should be able to reproduce it. We can check the error log in
t/servroot/logs/error.log.By running
nginx -p $dir_of_wasm_nginx_module/t/servroot/ -c $dir_of_wasm_nginx_module/t/servroot/conf/nginx.conf, we can start the Nginx, and then we can runcurl http://127.0.0.1:1984/t -ito reproduce it.Let’s add the built Nginx binary to the $PATH, like https://github.com/api7/wasm-nginx-module/blob/08f1424826004ffd000afddbff91c1181960293d/.github/workflows/test.yml#L70
Let’s add
after
What is the error message? Maybe it can be solved with the missing
rustup target add wasm32-wasi.