Skip to content

CFE-4742: Fixed simulate mode reporting both removal and install of the same package - #6332

Open
djbclark wants to merge 1 commit into
cfengine:masterfrom
djbclark:fix/simulate-pkg-mapremove
Open

CFE-4742: Fixed simulate mode reporting both removal and install of the same package#6332
djbclark wants to merge 1 commit into
cfengine:masterfrom
djbclark:fix/simulate-pkg-mapremove

Conversation

@djbclark

Copy link
Copy Markdown

Ticket: https://northerntech.atlassian.net/browse/CFE-4742

In DiffPkgOperations() and ManifestPkgOperations(), inserting an install message into the installed/present map set name_arch to NULL because the map took ownership of it as a key. The MapRemove() call that cancels a previous removal message ran after that, so it looked up a NULL key and matched nothing: a package recorded as removed and then installed was reported as both removed and installed. Moved the cancellation above the code that hands name_arch to the map.

The regression test feeds r,foo,, + i,foo,1.2.3, records to both functions: it fails before the fix and passes after, verified on x86_64 Linux (CI), Ubuntu 24.04 arm64 (dash), and macOS arm64.

AI-assisted. Full disclosure in the ticket: I reviewed the fix's logic with AI guidance and saw no issues, but I cannot personally vouch for the C itself — the correctness case rests on the discriminating regression test and CI above. If that does not meet the bar for human review, closing this is a fine outcome and the documented finding stands.

…ckage

In DiffPkgOperations() and ManifestPkgOperations(), inserting an install
message into the installed/present map set name_arch to NULL because the
map took ownership of it as a key. The MapRemove() call that cancels a
previous removal message ran after that, so it looked up a NULL key and
matched nothing. The cancellation was silently skipped exactly when an
install message had been inserted: a package recorded as removed and
then installed was reported as both removed and installed. In debug
builds a NULL key also fails an assertion in StringHash() once the map
outgrows the array-map stage.

Moved the cancellation above the code that hands name_arch to the map.

Changelog: Title
Ticket: CFE-4742

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
djbclark added a commit to frdminc/tendcf that referenced this pull request Aug 22, 2026
…re#6332)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@larsewi larsewi self-assigned this Aug 23, 2026
@cf-bottom

Copy link
Copy Markdown

Thanks for submitting a pull request! Maybe @craigcomstock can review this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants