aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-repro
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-09-01 19:54:55 +0200
committerDmitry Vyukov <dvyukov@google.com>2016-09-01 19:54:55 +0200
commit0e77b5a187da97820eca76b895ab221693249b6c (patch)
treef117250dba42f0e28850e2faa3d71ece92ad2015 /tools/syz-repro
parent27b03f4ba36faac74463cf4c699ac26b3548013c (diff)
manager, repro: unify VM monitoring
Unify and factor out VM monitoring loop used in syz-manager and syz-repro. This allows syz-repro to detect all the same bugs (e.g. "no output", "lost connection", etc). And also just deduplicates code.
Diffstat (limited to 'tools/syz-repro')
-rw-r--r--tools/syz-repro/repro.go44
1 files changed, 8 insertions, 36 deletions
diff --git a/tools/syz-repro/repro.go b/tools/syz-repro/repro.go
index 8c5cf09c2..f1fd621b0 100644
--- a/tools/syz-repro/repro.go
+++ b/tools/syz-repro/repro.go
@@ -67,9 +67,8 @@ func main() {
crashDesc, _, crashStart, _ := report.Parse(data)
if crashDesc == "" {
- log.Fatalf("can't find crash message in the log")
+ crashStart = len(data) // assuming VM hanged
}
- log.Printf("target crash: '%s'", crashDesc)
instances = make(chan VM, cfg.Count)
bootRequests = make(chan int, cfg.Count)
@@ -271,39 +270,12 @@ func testImpl(inst vm.Instance, command string, timeout time.Duration) (res bool
if err != nil {
log.Fatalf("failed to run command in VM: %v", err)
}
- var output []byte
- for {
- select {
- case out := <-outc:
- output = append(output, out...)
- if report.ContainsCrash(output) {
- timer := time.NewTimer(5 * time.Second).C
- loop:
- for {
- select {
- case out, ok := <-outc:
- if !ok {
- break loop
- }
- output = append(output, out...)
- case <-timer:
- break loop
- }
- }
- desc, _, _, _ := report.Parse(output)
- log.Printf("program crashed with '%s'", desc)
- return true
- }
- case err := <-errc:
- if err != nil {
- log.Printf("program crashed with result '%v'", err)
- return true
- }
- log.Printf("program did not crash")
- return false
- case <-shutdown:
- inst.Close()
- exit()
- }
+ desc, text, output, crashed, timedout := vm.MonitorExecution(outc, errc, false, false)
+ _, _ = text, output
+ if crashed || timedout {
+ log.Printf("program crashed with: %v", desc)
+ return true
}
+ log.Printf("program did not crash")
+ return false
}