From 5142e5aa3b3f41019136f156bc9ece61c0a17f42 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 6 Jul 2023 19:41:38 +0200 Subject: pkg/bisect: fix SYZFATAL bisections After the previous change, pkg/bisect is unable to bisect SYZFATAL errors. Fix the bug in the logic and add a test. --- pkg/bisect/bisect.go | 3 ++- pkg/bisect/bisect_test.go | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'pkg/bisect') diff --git a/pkg/bisect/bisect.go b/pkg/bisect/bisect.go index 9668144ef..3044ae081 100644 --- a/pkg/bisect/bisect.go +++ b/pkg/bisect/bisect.go @@ -803,7 +803,8 @@ func (env *env) isTransientError(rep *report.Report) bool { for _, t := range env.reportTypes { hadSyzFailure = hadSyzFailure || t == crash.SyzFailure } - return rep.Type == crash.SyzFailure && !hadSyzFailure + return rep.Type == crash.SyzFailure && + len(env.reportTypes) > 0 && !hadSyzFailure } func (env *env) saveDebugFile(hash string, idx int, data []byte) { diff --git a/pkg/bisect/bisect_test.go b/pkg/bisect/bisect_test.go index 47251b8cc..0c4775b0c 100644 --- a/pkg/bisect/bisect_test.go +++ b/pkg/bisect/bisect_test.go @@ -87,9 +87,9 @@ func (env *testEnv) Test(numVMs int, reproSyz, reproOpts, reproC []byte) ([]inst (!env.test.fix && commit >= env.test.culprit || env.test.fix && commit < env.test.culprit) { if env.test.flaky { - ret = crashErrors(1, numVMs-1, "crash occurs") + ret = crashErrors(1, numVMs-1, "crash occurs", env.test.reportType) } else { - ret = crashErrors(numVMs, 0, "crash occurs") + ret = crashErrors(numVMs, 0, "crash occurs", env.test.reportType) } return ret, nil } @@ -265,6 +265,7 @@ type BisectionTest struct { brokenEnd int infraErrStart int infraErrEnd int + reportType crash.Type // Range of commits that result in the same kernel binary signature. sameBinaryStart int sameBinaryEnd int @@ -428,6 +429,16 @@ var bisectionTests = []BisectionTest{ culprit: 500, isRelease: true, }, + // Tests that bisection returns the correct fix commit in case of SYZFATAL. + { + name: "fix-finds-fix-for-syzfatal", + fix: true, + startCommit: 400, + reportType: crash.SyzFailure, + commitLen: 1, + culprit: 500, + isRelease: true, + }, // Tests that fix bisection returns error when crash does not reproduce // on the original commit. { @@ -639,13 +650,14 @@ func checkTest(t *testing.T, test BisectionTest) { } } -func crashErrors(crashing, nonCrashing int, title string) []instance.EnvTestResult { +func crashErrors(crashing, nonCrashing int, title string, typ crash.Type) []instance.EnvTestResult { var ret []instance.EnvTestResult for i := 0; i < crashing; i++ { ret = append(ret, instance.EnvTestResult{ Error: &instance.CrashError{ Report: &report.Report{ Title: fmt.Sprintf("crashes at %v", title), + Type: typ, }, }, }) -- cgit mrf-deployment