aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-05-30 20:22:56 +0200
committerGitHub <noreply@github.com>2017-05-30 20:22:56 +0200
commitc4536c1435314a1b2c202ea52c95c6d67251e2cf (patch)
tree28d1ae8bd5bc68a62ab219b609c257866fcceca4
parent75b66eabef6ee2b89d89f31d90ff2ed9d3478c39 (diff)
parent29fc5b76cdfa2f32e7965f54aeb28356b93f3704 (diff)
Merge pull request #198 from prattmic/cleanup
all: cleanup executor/ipc interaction
-rw-r--r--executor/executor.cc3
-rw-r--r--ipc/ipc.go26
-rw-r--r--tools/syz-stress/stress.go8
3 files changed, 17 insertions, 20 deletions
diff --git a/executor/executor.cc b/executor/executor.cc
index cb31e0697..044410792 100644
--- a/executor/executor.cc
+++ b/executor/executor.cc
@@ -226,7 +226,8 @@ int main(int argc, char** argv)
// ptrace(PTRACE_SEIZE, 1, 0, 0x100040)
// This is unfortunate, but I don't have a better solution than ignoring it for now.
exitf("loop exited with status %d", status);
- return 0;
+ // Unreachable.
+ return 1;
}
void loop()
diff --git a/ipc/ipc.go b/ipc/ipc.go
index ce951aab6..5d579b479 100644
--- a/ipc/ipc.go
+++ b/ipc/ipc.go
@@ -617,36 +617,28 @@ func (c *command) exec(opts *ExecOpts) (output []byte, failed, hanged, restart b
}
status = int(reply[0])
if status == 0 {
+ // Program was OK.
<-hang
return
}
// Executor writes magic values into the pipe before exiting,
// so proceed with killing and joining it.
- status = int(reply[0])
}
- err0 = fmt.Errorf("executor did not answer")
c.abort()
output = <-c.readDone
- if err := c.wait(); <-hang && err != nil {
+ if err := c.wait(); <-hang {
hanged = true
+ // In all likelihood, this will be duplicated by the default
+ // case below, but that's fine.
output = append(output, []byte(err.Error())...)
output = append(output, '\n')
}
- switch status {
- case statusFail, statusError, statusRetry:
- default:
- if c.cmd.ProcessState != nil {
- sys := c.cmd.ProcessState.Sys()
- if ws, ok := sys.(syscall.WaitStatus); ok {
- status = ws.ExitStatus()
- }
- }
- }
// Handle magic values returned by executor.
switch status {
case statusFail:
err0 = ExecutorFailure(fmt.Sprintf("executor failed: %s", output))
case statusError:
+ err0 = fmt.Errorf("executor detected kernel bug")
failed = true
case statusRetry:
// This is a temporal error (ENOMEM) or an unfortunate
@@ -656,6 +648,14 @@ func (c *command) exec(opts *ExecOpts) (output []byte, failed, hanged, restart b
err0 = nil
hanged = false
restart = true
+ default:
+ // Failed to get a valid (or perhaps any) status from the
+ // executor.
+ //
+ // Once the executor is serving the status is always written to
+ // the pipe, so we don't bother to check the specific exit
+ // codes from wait.
+ err0 = fmt.Errorf("invalid (or no) executor status received: %d, executor exit: %s", status, c.cmd.ProcessState)
}
return
}
diff --git a/tools/syz-stress/stress.go b/tools/syz-stress/stress.go
index 5885e233d..4cf8d931f 100644
--- a/tools/syz-stress/stress.go
+++ b/tools/syz-stress/stress.go
@@ -8,7 +8,6 @@ import (
"fmt"
"math/rand"
"os"
- "regexp"
"runtime"
"sync"
"sync/atomic"
@@ -30,8 +29,6 @@ var (
flagLogProg = flag.Bool("logprog", false, "print programs before execution")
flagGenerate = flag.Bool("generate", true, "generate new programs, otherwise only mutate corpus")
- failedRe = regexp.MustCompile("runtime error: |panic: |Panic: ")
-
statExec uint64
gate *ipc.Gate
)
@@ -105,11 +102,10 @@ func execute(pid int, env *ipc.Env, p *prog.Prog) {
if err != nil {
fmt.Printf("failed to execute executor: %v\n", err)
}
- paniced := failedRe.Match(output)
- if failed || hanged || paniced || err != nil {
+ if failed || hanged || err != nil {
fmt.Printf("PROGRAM:\n%s\n", p.Serialize())
}
- if failed || hanged || paniced || err != nil || *flagOutput {
+ if failed || hanged || err != nil || *flagOutput {
os.Stdout.Write(output)
}
}