aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-11-07 15:50:59 +0100
committerDmitry Vyukov <dvyukov@google.com>2024-11-11 15:41:26 +0000
commiteb96afce744b5fa3e48bec422494c8c5e1b6fbab (patch)
tree3e6b04773e33e18b985c69cba5a031164db55ae7 /tools
parent163d3bfa99dbc46d515c47215bf61f8c71177669 (diff)
tools/syz-declextract: provoke non-determinism
Provoke any non-determinism caused by file order early.
Diffstat (limited to 'tools')
-rw-r--r--tools/syz-declextract/run.go7
1 files changed, 7 insertions, 0 deletions
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))