aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-12-16 13:53:22 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-12-16 13:54:07 +0100
commitc7e64e2b4f3a9d7734a92aebc53f285cd6afd94b (patch)
treebb55753c91c0076a65424d1eaf0142ca13475004 /vm
parent4bc415c2305c2489109f79caf02b8a10fe5036bb (diff)
vm: don't call Diagnose when VM hasn't crashed
Fixes #875
Diffstat (limited to 'vm')
-rw-r--r--vm/vm.go10
-rw-r--r--vm/vm_test.go21
2 files changed, 22 insertions, 9 deletions
diff --git a/vm/vm.go b/vm/vm.go
index 26bd21745..b403956a6 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -230,10 +230,13 @@ type monitor struct {
}
func (mon *monitor) extractError(defaultError string) *report.Report {
+ crashed := defaultError != "" || !mon.canExit
+ if crashed {
+ mon.inst.Diagnose()
+ }
// Give it some time to finish writing the error message.
- mon.inst.Diagnose()
mon.waitForOutput()
- if bytes.Contains(mon.output, []byte(fuzzerPreemptedStr)) {
+ if bytes.Contains(mon.output, []byte("SYZ-FUZZER: PREEMPTED")) {
return nil
}
if !mon.reporter.ContainsCrash(mon.output[mon.matchPos:]) {
@@ -250,6 +253,9 @@ func (mon *monitor) extractError(defaultError string) *report.Report {
}
return rep
}
+ if !crashed && mon.inst.Diagnose() {
+ mon.waitForOutput()
+ }
rep := mon.reporter.Parse(mon.output[mon.matchPos:])
if rep == nil {
panic(fmt.Sprintf("reporter.ContainsCrash/Parse disagree:\n%s", mon.output[mon.matchPos:]))
diff --git a/vm/vm_test.go b/vm/vm_test.go
index 1c66166f7..626ad62cb 100644
--- a/vm/vm_test.go
+++ b/vm/vm_test.go
@@ -107,11 +107,16 @@ var tests = []*Test{
Body: func(outc chan []byte, errc chan error) {
errc <- nil
},
+ },
+ {
+ Name: "#875-diagnose-bugs-2",
+ Body: func(outc chan []byte, errc chan error) {
+ errc <- nil
+ },
Report: &report.Report{
- Title: "BUG: DIAGNOSE",
- // TODO: this is wrong.
- Report: []byte(
- "BUG: DIAGNOSE\n",
+ Title: lostConnectionCrash,
+ Output: []byte(
+ "DIAGNOSE\n",
),
},
},
@@ -148,10 +153,9 @@ var tests = []*Test{
},
Report: &report.Report{
Title: "BUG: bad",
- // TODO: this is wrong.
Report: []byte(
- "DIAGNOSE\n" +
- "BUG: bad\n",
+ "BUG: bad\n" +
+ "DIAGNOSE\n",
),
},
},
@@ -298,4 +302,7 @@ func testMonitorExecution(t *testing.T, test *Test) {
if !bytes.Equal(test.Report.Report, rep.Report) {
t.Fatalf("want report:\n%s\n\ngot report:\n%s\n", test.Report.Report, rep.Report)
}
+ if test.Report.Output != nil && !bytes.Equal(test.Report.Output, rep.Output) {
+ t.Fatalf("want output:\n%s\n\ngot output:\n%s\n", test.Report.Output, rep.Output)
+ }
}