ashtonmeuser / godot-wasm

Interact with WebAssembly modules from Godot
https://github.com/ashtonmeuser/godot-wasm/wiki
MIT License
193 stars 11 forks source link

WASI args_get segfaults in Windows bash #48

Closed ashtonmeuser closed 1 year ago

ashtonmeuser commented 1 year ago

Running test suites reveals a segfault (Process completed with exit code 139.) on exiting Godot. Does not happen on uninitialization of Wasm object but rather on Godot exiting. Removing any access to Process.argv in module built with AssemblyScript prevents issue. Can not reproduce when running tests on macOS, Linux, or Windows via Powershell.

Shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0} Godot Version: Godot Engine v4.0.2.stable.official.7a0977ce2 Command: ./Godot_v4.0.2-stable_win64.exe --headless --no-window --debug --path examples/wasm-test OS: Microsoft Windows Server 2022 10.0.20348

ashtonmeuser commented 1 year ago

I believe this was actually related to the implementation of wasi_snapshot_preview1.random_get. Specifically, the Godot 4 branch used Crypto().generate_random_bytes(n) creating an orphaned RefCounted object. This was fixed in commit 677a5d122213fa8330ac402c7c8fbff5b73fe536. Commit 989f612b2e0c2eb0773b478712a9c4a645ab9edd changed Windows tests to run in bash with no issue.