Skip to content

Commit

Permalink
fix: Do not close wazero module on error (#3758) (#3759)
Browse files Browse the repository at this point in the history
wazero takes care not to leak modules when `InstantiateModule` returns
an error.

This means that sqlc will call `result.Close` a second time if a non nil
module was returned, which causes a segfault.
  • Loading branch information
edman authored Dec 27, 2024
1 parent 86c1d77 commit cfe6c55
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/ext/wasm/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (r *Runner) Invoke(ctx context.Context, method string, args any, reply any,
}

result, err := runtimeAndCode.rt.InstantiateModule(ctx, runtimeAndCode.code, conf)
if result != nil {
if err == nil {
defer result.Close(ctx)
}
if cerr := checkError(err, stderr); cerr != nil {
Expand Down

0 comments on commit cfe6c55

Please sign in to comment.