fix(verify): fix flaky JIT tests with global buffers and KeepAlive
This commit is contained in:
+4
-9
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
@@ -192,7 +193,7 @@ func (k *Kernel) FuzzFunc(name string, sig funcSig, goCode []byte, iterations in
|
||||
if result.FirstFail == "" {
|
||||
result.FirstFail = fmt.Sprintf("iter %d: gasm call: %v", i, err)
|
||||
}
|
||||
releaseBufs(bufs)
|
||||
runtime.KeepAlive(bufs)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -203,7 +204,7 @@ func (k *Kernel) FuzzFunc(name string, sig funcSig, goCode []byte, iterations in
|
||||
if result.FirstFail == "" {
|
||||
result.FirstFail = fmt.Sprintf("iter %d: go call: %v", i, err)
|
||||
}
|
||||
releaseBufs(bufs)
|
||||
runtime.KeepAlive(bufs)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -221,7 +222,7 @@ func (k *Kernel) FuzzFunc(name string, sig funcSig, goCode []byte, iterations in
|
||||
} else {
|
||||
result.Matches++
|
||||
}
|
||||
releaseBufs(bufs)
|
||||
runtime.KeepAlive(bufs)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -384,9 +385,3 @@ func equalBytes(a, b []byte) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func releaseBufs(bufs [][]byte) {
|
||||
// Keep buffers alive until after the call; nothing to free in Go,
|
||||
// but this prevents the compiler from collecting them too early.
|
||||
_ = bufs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user