Closed trcrsired closed 2 months ago
You need -W wmemcheck=y
/--wasm wmemcheck=y
. Looks like the docs didn't get changed when the cli options got changed a while back.
You need
-W wmemcheck=y
/--wasm wmemcheck=y
. Looks like the docs didn't get changed when the cli options got changed a while back.
#include<fcntl.h>
#include<unistd.h>
int main()
{
int fd = open("example.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
}
$ wasmtime --wasm wmemcheck=y --dir . ./test.wasm
Error: failed to run main module `./test.wasm`
Caused by:
0: failed to invoke command default
1: error while executing at wasm backtrace:
0: 0xb3e - test.wasm!dlmalloc
1: 0x232b - test.wasm!calloc
2: 0x2537 - test.wasm!internal_register_preopened_fd_unlocked
3: 0x24ac - test.wasm!__wasilibc_populate_preopens
4: 0x266d - test.wasm!__wasilibc_find_abspath
5: 0x264a - test.wasm!__wasilibc_find_relpath
6: 0x23ae - test.wasm!open
7: 0x2f09 - test.wasm!__main_void
8: 0x1a7 - test.wasm!_start
2: Invalid store at addr 0x1066c of size 4
calloc does not work right?
It looks like wmemcheck's heuristic for finding malloc
and avoiding instrumenting stores within the malloc implementation itself is no longer valid -- here the implementation looks for functions named malloc
and free
, but at some point wasi-libc must have renamed malloc
to dlmalloc
.
You're welcome to submit a PR to accept both options. Note that wmemcheck
is described in the documentation as experimental and unfinished -- we had an intern build it last year and it was an excellent start but it needs a little more polish before we mark the option as "polished" and included in default builds. For example (to save you the trouble of filing another bug report!), it also doesn't support realloc
currently.
It looks like wmemcheck's heuristic for finding
malloc
and avoiding instrumenting stores within the malloc implementation itself is no longer valid -- here the implementation looks for functions namedmalloc
andfree
, but at some point wasi-libc must have renamedmalloc
todlmalloc
.You're welcome to submit a PR to accept both options. Note that
wmemcheck
is described in the documentation as experimental and unfinished -- we had an intern build it last year and it was an excellent start but it needs a little more polish before we mark the option as "polished" and included in default builds. For example (to save you the trouble of filing another bug report!), it also doesn't supportrealloc
currently.
So the implementation is still ongoing and far from usable at this point right? And if the symbols got stripped, it cannot detect issues either right since now the wasmtime cannot find malloc and calloc
That's correct.
I build wasmtime with this command and still it does not find --wmemcheck why?