forked from wasmerio/wasmer-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes wasmerio#364 Fixes wasmerio#391 It's a very common pattern to save exported function for the purpose of future invocation: ``` fn, err := instance.Exports.GetFunction("...") ... return fn(...) ``` Such pattern of use is bound to run into issues when the code will crash occasionally when invoking fn. This happens *if* after the function instantiation the instance is never used/accessed again. In those cases, Go GC may GC the instance object -- and if that happens the call to fn will likely panic. A safer version of GetFunction method has been added on the instance: ``` fn, release, err := instance.GetFunctionSafe(...) // handle err defer release(instance) ``` By returning release function that must be called with the owning instance object, we ensure the instance remains live as long as the instance function may be called. Indeed, the release function is nothing more than a typed runtime.KeepAlive call. Signed-off-by: Yevgeniy Miretskiy <[email protected]> Release note (<category, see below>): <what> <show> <why>
- Loading branch information
Yevgeniy Miretskiy
committed
Jan 9, 2025
1 parent
d199c2b
commit a4ecc77
Showing
4 changed files
with
118 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
module github.com/wasmerio/wasmer-go | ||
|
||
go 1.14 | ||
go 1.22 | ||
|
||
require github.com/stretchr/testify v1.7.0 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.