diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2022-06-03 13:13:18 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2022-06-03 17:26:50 +0200 |
| commit | 438e961a3d21d171d2a07c566f0c512b1481e18c (patch) | |
| tree | 72c4e790e381a9a6f92e2e62e6a0095073dea0f2 /prog/any_test.go | |
| parent | 56250633ec0a1d1a77a9f35dd6fe7175142d43d9 (diff) | |
prog: fix panic in squash of out_overlay structs
We are seeing crashes like:
panic: call overlay_uses: result arg overlayres64 references out-of-tree result
This is caused by fact that we completely discard out_overlay part during squashing.
So if it contains any resources used later, we will get out-of-tree references.
Prohibit squashing structs with out_overlay attribute.
Alternatives would be either to produce out_overlay struct after squashing as well,
or remove all resources in out part from the program.
But it does not seem to be worth the complexity (we have few complex structs
with out_overlay, if any).
Diffstat (limited to 'prog/any_test.go')
| -rw-r--r-- | prog/any_test.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/prog/any_test.go b/prog/any_test.go index f021eeda7..2d08d92fb 100644 --- a/prog/any_test.go +++ b/prog/any_test.go @@ -45,12 +45,21 @@ func TestSquash(t *testing.T) { // nolint: lll tests := []struct { prog string - squashed string + squashed string // leave empty if the arg must not be squashed }{ { `foo$any0(&(0x7f0000000000)={0x11, 0x11223344, 0x2233, 0x1122334455667788, {0x1, 0x7, 0x1, 0x1, 0x1bc, 0x4}, [{@res32=0x0, @i8=0x44, "aabb"}, {@res64=0x1, @i32=0x11223344, "1122334455667788"}]})`, `foo$any0(&(0x7f0000000000)=ANY=[@ANYBLOB="1100000044332211223300000000000088776655443322117d00bc11", @ANYRES32=0x0, @ANYBLOB="0000000044aabb00", @ANYRES64=0x1, @ANYBLOB="44332211112233445566778800000000"])`, }, + { + // Squashing of structs with out_overlay is not supported yet + // (used to panic, see isComplexPtr). + ` +overlay_any(&(0x7f0000000000)=@overlay2={0x0, 0x0, <r0=>0x0, 0x0}) +overlay_uses(0x0, 0x0, 0x0, r0) +`, + ``, + }, } for i, test := range tests { t.Run(fmt.Sprint(i), func(t *testing.T) { @@ -59,6 +68,12 @@ func TestSquash(t *testing.T) { t.Fatalf("failed to deserialize prog: %v", err) } ptrArg := p.Calls[0].Args[0].(*PointerArg) + if test.squashed == "" { + if target.isComplexPtr(ptrArg) { + t.Fatalf("arg is complex and can be squashed") + } + return + } if !target.isComplexPtr(ptrArg) { t.Fatalf("arg is not complex") } |
