Skip to content

fix(suite/loader): avoid sharing backing arrays between matrix combinations - #323

Merged
poiana merged 1 commit into
falcosecurity:mainfrom
arpitjain099:fix/matrix-combination-aliasing
Sep 12, 2026
Merged

poiana merged 1 commit into
falcosecurity:mainfrom
arpitjain099:fix/matrix-combination-aliasing

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind documentation

/kind tests

/kind feature

If this PR prepares a chart release, uncomment:

/kind chart-release

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area commands

/area pkg

/area events

/area chart

/area automation

What this PR does / why we need it:

combine derived each new combination with newComb := comb followed by an append. That copies the slice header only, and generateCombinations calls combine once per value of the current key while passing the same combs each time, so as soon as a combination carries spare capacity the siblings built from it write to the same backing array and the last value wins.

Combinations reach that state after the third key, because the append that grows them from two to three elements leaves room for a fourth. From four keys on, half of the matrix is silently lost: the number of generated tests is still right, so nothing looks wrong, but the tests are duplicates. A four-key spec with two values each expands to sixteen tests covering eight combinations, and one of the values of the last key never appears at all.

Copying the combination before appending keeps each branch independent.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Added pkg/test/loader/template_test.go, which loads a four-key matrix template through Loader.Load and counts distinct combinations. On main it reports 8 of 16 (with d1 missing from every case); with the change it reports 16. The package had no tests before, so this is the first file there.

The rest of ./pkg/... builds and tests the same before and after; the packages that fail to build here are the Linux-only syscall steps and libcap, which is expected on darwin.

…ations

combine() extended each existing combination with newComb := comb followed by
an append, which copies the slice header only. generateCombinations calls
combine once per value of the current key with the same combs slice, so once a
combination has spare capacity the siblings derived from it append into the same
backing array and only the last value survives.

From the fourth key onwards this silently halves a matrix: the number of
generated tests stays correct, so the loss is invisible, but the combinations
are duplicated and one value of the last key never appears.

Copy the combination before appending, and add a loader test that expands a
four-key matrix through Loader.Load and counts distinct combinations.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@poiana

poiana commented Sep 9, 2026

Copy link
Copy Markdown

Welcome @arpitjain099! It looks like this is your first PR to falcosecurity/event-generator 🎉

@poiana poiana added the size/M label Sep 9, 2026

@ekoops ekoops left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@poiana

poiana commented Sep 12, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arpitjain099, ekoops

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana

poiana commented Sep 12, 2026

Copy link
Copy Markdown

LGTM label has been added.

DetailsGit tree hash: 85057e22d9caf0b5ea1db9304da7012b3efd1c70

@poiana
poiana merged commit 07d2936 into falcosecurity:main Sep 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants