From eb96afce744b5fa3e48bec422494c8c5e1b6fbab Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 7 Nov 2024 15:50:59 +0100 Subject: tools/syz-declextract: provoke non-determinism Provoke any non-determinism caused by file order early. --- tools/syz-declextract/run.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tools') diff --git a/tools/syz-declextract/run.go b/tools/syz-declextract/run.go index f49b1f9f3..54fbf1277 100644 --- a/tools/syz-declextract/run.go +++ b/tools/syz-declextract/run.go @@ -10,6 +10,7 @@ import ( "flag" "fmt" "io/fs" + "math/rand" "os" "os/exec" "path/filepath" @@ -17,6 +18,7 @@ import ( "slices" "strconv" "strings" + "time" "github.com/google/syzkaller/pkg/ast" "github.com/google/syzkaller/pkg/osutil" @@ -55,6 +57,11 @@ func main() { if err := json.Unmarshal(fileData, &cmds); err != nil { tool.Fail(err) } + // Shuffle the order detect any non-determinism caused by the order early. + // The result should be the same regardless. + rand.New(rand.NewSource(time.Now().UnixNano())).Shuffle(len(cmds), func(i, j int) { + cmds[i], cmds[j] = cmds[j], cmds[i] + }) outputs := make(chan *output, len(cmds)) files := make(chan string, len(cmds)) -- cgit mrf-deployment