From bad18a53de8fa8d3d097e3d701efb72a014661cb Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 4 Jan 2022 15:29:10 +0100 Subject: pkg/compiler: require stricter resource constructors Don't consider syscalls that return resources in unions/arrays as constructors. Unions and arrays are problematic because we don't have directed generation in prog.randGen.createResource() and can fail to generate a syscall that returns a particular resource (generate a wrong union option that does not contain the necessary resource). This leads to the following panics: panic: failed to create a resource ifindex with ioctl$sock_SIOCGIFCONF Require each resource to have a constructor syscall that returns the resource outside of unions/arrays. --- pkg/compiler/gen.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pkg/compiler/gen.go') diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go index 89571c966..3d5517ae8 100644 --- a/pkg/compiler/gen.go +++ b/pkg/compiler/gen.go @@ -379,7 +379,8 @@ func (comp *compiler) layoutStructFields(t *prog.StructType, varlen, packed bool t.Fields = comp.finalizeStructFields(t, newFields, varlen, structAlign, byteOffset, bitOffset) } -func (comp *compiler) finalizeStructFields(t *prog.StructType, fields []prog.Field, varlen bool, structAlign, byteOffset, bitOffset uint64) []prog.Field { +func (comp *compiler) finalizeStructFields(t *prog.StructType, fields []prog.Field, varlen bool, + structAlign, byteOffset, bitOffset uint64) []prog.Field { if bitOffset != 0 { pad := roundup(bitOffset, 8) / 8 byteOffset += pad -- cgit mrf-deployment