bytecodealliance / wasmtime-dotnet

.NET embedding of Wasmtime https://bytecodealliance.github.io/wasmtime-dotnet/
Apache License 2.0
422 stars 51 forks source link

Move allocating the `Caller` into the `try` block (follow-up to #188) #193

Closed kpreisser closed 1 year ago

kpreisser commented 1 year ago

In #188, I missed that allocating the Caller was done outside of the try block, and that could potentially throw an OutOfMemoryException when the system is low on memory.

This PR moves allocating the Caller into the try block, to prevent the .NET Runtime on Windows unwinding the stack to the next .NET exception handler in case the allocation threw an OOME (which would be incompatible with Wasmtime) and instead attempts to convert it into a wasm_trap_t*.

Thanks!

peterhuene commented 1 year ago

Thanks!