aboutsummaryrefslogtreecommitdiffstats
path: root/prog/mutation.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-12-28 21:31:00 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-02-19 11:54:01 +0000
commit31179bc75602cbe8f0421b44f19ff1b960039644 (patch)
tree9804abe8e2ca0218da0e2c71b61a8b411f26e800 /prog/mutation.go
parented571339c6ff5ed764283737a0aa68451085e84d (diff)
prog: support conditional fields
pkg/compiler restructures conditional fields in structures into unions, so we only have to implement the support for unions. Semantics is as follows: If a union has conditions, syzkaller picks the first field whose condition matches. Since we require the last union field to have no conditions, we can always construct an object. Changes from this commit aim at ensuring that the selected union fields always follow the rule above.
Diffstat (limited to 'prog/mutation.go')
-rw-r--r--prog/mutation.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/prog/mutation.go b/prog/mutation.go
index 47b682342..cf93ce4eb 100644
--- a/prog/mutation.go
+++ b/prog/mutation.go
@@ -198,6 +198,8 @@ func (ctx *mutator) mutateArg() bool {
ok = false
continue
}
+ moreCalls, fieldsPatched := r.patchConditionalFields(c, s)
+ calls = append(calls, moreCalls...)
p.insertBefore(c, calls)
idx += len(calls)
for len(p.Calls) > ctx.ncalls {
@@ -208,7 +210,7 @@ func (ctx *mutator) mutateArg() bool {
panic(fmt.Sprintf("wrong call index: idx=%v calls=%v p.Calls=%v ncalls=%v",
idx, len(calls), len(p.Calls), ctx.ncalls))
}
- if updateSizes {
+ if updateSizes || fieldsPatched {
p.Target.assignSizesCall(c)
}
}