CosmWasm / wasmd

Basic cosmos-sdk app with web assembly smart contracts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[wasmd v0.43]: possible UB inside wasmvm - contract init dlmalloc panic in rust 1.78

jstuczyn opened this issue · comments

Hi!

I wasn't sure whether to post this issue in this repo or the wasmvm one, so if it's in the wrong place, I apologise.

Ever since updating my local rust toolchain to 1.78, any contract built locally fails to get initialised on chain due to the panic inside wasmvm:

Error: rpc error: code = Unknown desc = rpc error: code = Unknown desc = failed to execute message; message index: 0: Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: Aborted: panicked at /rust/deps/dlmalloc-0.2.6/src/dlmalloc.rs:1198:13:
assertion failed: psize <= size + max_overhead: instantiate wasm contract failed [CosmWasm/wasmd@v0.43.0/x/wasm/keeper/keeper.go:325] With gas wanted: '18446744073709551615' and gas used: '110152' : unknown request

Note that everything works perfectly fine under 1.77.2.

I've noticed the identical issue coming up for wasm-bindgen users:
alexcrichton/dlmalloc-rs#41 + rustwasm/wasm-pack#1389 which seems to have been due to not taking alignment correctly into consideration: rustwasm/wasm-bindgen#3463.

which would probably make sense given the associated 1.78 changes: https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#asserting-unsafe-preconditions + https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#deterministic-realignment

Therefore, I suspect there might be some UB inside the wasmvm that might be worth investigating