diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-03-05 15:14:07 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-03-08 10:56:47 +0000 |
| commit | 6387f6b7d487e2a77d753ad28c1074e39c17c3ca (patch) | |
| tree | feb7cac9b567eb2346a093e6b5a1962524b310ae /prog/expr_test.go | |
| parent | cf82cde132b42c09ac539191ca2dfdab5d810c93 (diff) | |
prog: fix resource leak during replaceArg() of union fields
The replaced union field may contain resource references that must also
be cleaned up.
The bug was triggered via methods that patch conditional fields, so
let's add stress tests for the conditional fields + resources
combination.
Reported-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'prog/expr_test.go')
| -rw-r--r-- | prog/expr_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/prog/expr_test.go b/prog/expr_test.go index f6c8c8603..adff50c6a 100644 --- a/prog/expr_test.go +++ b/prog/expr_test.go @@ -42,6 +42,23 @@ func TestGenerateConditionalFields(t *testing.T) { } } +func TestConditionalResources(t *testing.T) { + // Let's stress test the code and rely on various internal checks. + target, rs, _ := initRandomTargetTest(t, "test", "64") + ct := target.BuildChoiceTable(nil, map[*Syscall]bool{ + target.SyscallMap["test$create_cond_resource"]: true, + target.SyscallMap["test$use_cond_resource"]: true, + }) + iters := 500 + if testing.Short() { + iters /= 10 + } + for i := 0; i < iters; i++ { + p := target.Generate(rs, 10, ct) + p.Mutate(rs, 10, ct, nil, nil) + } +} + func TestMutateConditionalFields(t *testing.T) { target, rs, _ := initRandomTargetTest(t, "test", "64") ct := target.DefaultChoiceTable() |
