diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-05-03 07:13:00 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-05-03 08:23:29 +0000 |
| commit | 2ca36995aaecbfcd2268b19cf3445fdf64bb508e (patch) | |
| tree | 8b4a125e7f593a6c70b754d954f0f3d0b89dc67b /pkg/compiler/gen.go | |
| parent | 375d4445a31b220afd91f42a7aa1b610d689a897 (diff) | |
prog: fix panic during squashing
Netbsd syzbot instance crashes trying to squash a pointer.
Pointers must not be squashed. This happens because of
recursive ucontext_t type that contains a pointer to itself.
When we assign SquashableElem recursive struct types may not be fully
generated yet, and ForeachArgType won't observe all types.
Assign SquashableElem after all types are fully generated.
Diffstat (limited to 'pkg/compiler/gen.go')
| -rw-r--r-- | pkg/compiler/gen.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go index f91e2502c..1fcf8dcac 100644 --- a/pkg/compiler/gen.go +++ b/pkg/compiler/gen.go @@ -103,6 +103,14 @@ func (comp *compiler) genSyscalls() []*prog.Syscall { calls = append(calls, comp.genSyscall(n, callArgSizes[n.CallName])) } } + // We assign SquashableElem here rather than during pointer type generation + // because during pointer generation recursive struct types may not be fully + // generated yet, thus ForeachArgType won't observe all types. + prog.ForeachTypePost(calls, func(typ prog.Type, ctx *prog.TypeCtx) { + if ptr, ok := typ.(*prog.PtrType); ok { + ptr.SquashableElem = isSquashableElem(ptr.Elem, ptr.ElemDir) + } + }) sort.Slice(calls, func(i, j int) bool { return calls[i].Name < calls[j].Name }) |
