Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiating compiled module results in nil pointer dereference in v1.8.2 but not v1.6.0 #2358

Open
davidmdm opened this issue Jan 8, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@davidmdm
Copy link

davidmdm commented Jan 8, 2025

Describe the bug
Instantiating compiled module results in nil pointer dereference in v1.8.2 but not v1.6.0

To Reproduce

Clone the example repository, checkout the set-exitcode-deref-panic branch and run the tests:

git clone https://github.com/davidmdm/wzbug.git
cd wzbug
git checkout set-exitcode-deref-panic
./test.sh

Expected behavior

The module should instantiate and run properly as it did with v1.6.0 without panic.

Screenshots

Using: github.com/tetratelabs/wazero v1.6.0

---

Using: github.com/tetratelabs/wazero v1.8.2

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1042fcbd0]

goroutine 1 [running]:
github.com/tetratelabs/wazero/internal/wasm.(*ModuleInstance).setExitCode(...)
	/Users/davidmdm/go/pkg/mod/github.com/tetratelabs/[email protected]/internal/wasm/module_instance.go:142
github.com/tetratelabs/wazero/internal/wasm.(*ModuleInstance).CloseWithExitCode(0x10449b5d8?, {0x10449c5f0?, 0x104661c00?}, 0x22e6f00?)
	/Users/davidmdm/go/pkg/mod/github.com/tetratelabs/[email protected]/internal/wasm/module_instance.go:101 +0x20
github.com/tetratelabs/wazero/internal/wasm.(*ModuleInstance).Close(0x14000074120?, {0x10449c5f0?, 0x104661c00?})
	/Users/davidmdm/go/pkg/mod/github.com/tetratelabs/[email protected]/internal/wasm/module_instance.go:96 +0x28
github.com/davidmdm/wzbug/wasi.Execute.func2()
	/Users/davidmdm/Documents/coding/exp/wazerobug/wasi/wasi.go:85 +0x34
github.com/davidmdm/wzbug/wasi.Execute({0x10449c5f0, 0x104661c00}, {{0x0, 0x0, 0x0}, {0x10449e400, 0x1400002e140}, {0x1043c3b05, 0x3}, {0x10449b538, ...}, ...})
	/Users/davidmdm/Documents/coding/exp/wazerobug/wasi/wasi.go:93 +0xd58
main.run()
	/Users/davidmdm/Documents/coding/exp/wazerobug/main.go:52 +0x428
main.main()
	/Users/davidmdm/Documents/coding/exp/wazerobug/main.go:15 +0x1c
exit status 2

Environment (please complete the relevant information):

  • Go version: 1.23.4
  • wazero Version: v1.6.0 & v1.8.2
  • Host architecture: arm64
  • Runtime mode: compiler
@davidmdm davidmdm added the bug Something isn't working label Jan 8, 2025
@davidmdm
Copy link
Author

davidmdm commented Jan 8, 2025

Note this also fails using v1.7.0

This occurs when using a compiled module with a cache directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant