fix(verify): fix flaky JIT tests with global buffers and KeepAlive
Test / vet (push) Successful in 49s
Test / test (push) Failing after 2m9s
Test / build (push) Skipped

This commit is contained in:
2026-08-05 23:09:54 +02:00
parent 23b3d3e152
commit 19b37569c0
10 changed files with 323 additions and 38 deletions
+4 -9
View File
@@ -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
}