diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-08-30 14:17:47 -0700 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-08-30 21:45:03 -0700 |
| commit | e8dd2c6713522707b3b89884eb95601cdf9bc9be (patch) | |
| tree | 9df12a938af90c06794ec9f60920d59330766ed1 /prog/rand.go | |
| parent | 6ba5fe3e62880ddf8aeec68ab44eabaa8bc148b8 (diff) | |
prog: add concept of "special pointers"
Currently we only generate either valid user-space pointers or NULL.
Extend NULL to a set of special pointers that we will use in programs.
All targets now contain 3 special values:
- NULL
- 0xfffffffffffffff (invalid kernel pointer)
- 0x999999999999999 (non-canonical address)
Each target can add additional special pointers on top of this.
Also generate NULL/special pointers for non-opt ptr's.
This restriction was always too restrictive. We may want to generate
them with very low probability, but we do want to generate them.
Also change pointers to NULL/special during mutation
(but still not in the opposite direction).
Diffstat (limited to 'prog/rand.go')
| -rw-r--r-- | prog/rand.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/prog/rand.go b/prog/rand.go index 7bded23c6..7f5597f82 100644 --- a/prog/rand.go +++ b/prog/rand.go @@ -515,7 +515,7 @@ func (r *randGen) generateArgImpl(s *state, typ Type, ignoreSpecial bool) (arg A } }() if r.recDepth[name] >= 3 { - return MakeNullPointerArg(typ), nil + return MakeSpecialPointerArg(typ, 0), nil } } } @@ -673,6 +673,10 @@ func (a *UnionType) generate(r *randGen, s *state) (arg Arg, calls []*Call) { } func (a *PtrType) generate(r *randGen, s *state) (arg Arg, calls []*Call) { + if r.oneOf(1000) { + index := r.rand(len(r.target.SpecialPointers)) + return MakeSpecialPointerArg(a, index), nil + } inner, calls := r.generateArg(s, a.Type) arg = r.allocAddr(s, a, inner.Size(), inner) return arg, calls |
