bytecodealliance / wasm-micro-runtime

WebAssembly Micro Runtime (WAMR)
Apache License 2.0
4.97k stars 627 forks source link

A possible memory leak issue in wasi-nn.c #2612

Closed zhen9910 closed 1 year ago

zhen9910 commented 1 year ago

A module instance is inserted into an internal wasi-nn hashmap when wasm runtime gets wasi-nn context, but is not removed when destroying wasi-nn context, which may cause memory leak and get a stale instance or context.

I found this issue during a test where a wasi-nn enabled host application tried to load and unload a wasi-nn wasm module repeatedly. This issue looks gone after removing the instance in wasi_nn_destroy.

zhen9910 commented 1 year ago

please review the created PR: https://github.com/bytecodealliance/wasm-micro-runtime/pull/2613

tonibofarull commented 1 year ago

You are right, thanks!