From afa9178d57c9cf0cbd11643ac72e4da22c85ab2c Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 20 Oct 2017 11:10:51 +0200 Subject: pkg/ipc: fix reading comp hints if/else branches are intermixed --- pkg/ipc/ipc.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'pkg/ipc') diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go index 8abf54054..e77b0acee 100644 --- a/pkg/ipc/ipc.go +++ b/pkg/ipc/ipc.go @@ -432,22 +432,26 @@ func (env *Env) readOutCoverage(p *prog.Prog) (info []CallInfo, err0 error) { compMap := make(prog.CompMap) for j := uint32(0); j < compsSize; j++ { var typ uint32 - var op1, op2 uint64 if !readOutAndSetErr(&typ, - "executor %v: failed while reading type of comparison %v", env.pid, j) { + "executor %v: failed while reading type of comparison %v/%v", + env.pid, callIndex, j) { return } if typ > compConstMask|compSizeMask { - err0 = fmt.Errorf("executor %v: got wrong value (%v) while reading type of comparison %v", - env.pid, typ, j) + err0 = fmt.Errorf("executor %v: got wrong value (%v) while reading type of comparison %v/%v", + env.pid, typ, callIndex, j) return } - isSize8 := (typ & compSizeMask) == compSize8 - isConst := (typ & compConstMask) != 0 arg1ErrString := "executor %v: failed while reading op1 of comparison %v" arg2ErrString := "executor %v: failed while reading op2 of comparison %v" - if isSize8 { + var op1, op2 uint64 + if (typ & compSizeMask) == compSize8 { + if !readOut64(&op1, arg1ErrString, env.pid, j) || + !readOut64(&op2, arg2ErrString, env.pid, j) { + return + } + } else { var tmp1, tmp2 uint32 if !readOutAndSetErr(&tmp1, arg1ErrString, env.pid, j) || !readOutAndSetErr(&tmp2, arg2ErrString, env.pid, j) { @@ -455,18 +459,12 @@ func (env *Env) readOutCoverage(p *prog.Prog) (info []CallInfo, err0 error) { } op1 = uint64(tmp1) op2 = uint64(tmp2) - } else { - if !readOut64(&op1, arg1ErrString, env.pid, j) || - !readOut64(&op2, arg2ErrString, env.pid, j) { - return - } } if op1 == op2 { - // It's useless to store such comparisons. - continue + continue // it's useless to store such comparisons } compMap.AddComp(op2, op1) - if isConst { + if (typ & compConstMask) != 0 { // If one of the operands was const, then this operand is always // placed first in the instrumented callbacks. Such an operand // could not be an argument of our syscalls (because otherwise -- cgit mrf-deployment