Skip to content

fix(build): clone opts before appending to avoid cross-config stomp in concurrent resolves - #2487

Merged
markusthoemmes merged 1 commit into
chainguard-dev:mainfrom
markusthoemmes:fix-concurrent-opts-race
Sep 10, 2026
Merged

fix(build): clone opts before appending to avoid cross-config stomp in concurrent resolves#2487
markusthoemmes merged 1 commit into
chainguard-dev:mainfrom
markusthoemmes:fix-concurrent-opts-race

Conversation

@markusthoemmes

Copy link
Copy Markdown
Member

LockImageConfigurationWithPackages appended WithImageConfiguration onto the caller's opts slice. When that slice has spare capacity and is shared across concurrent LockImageConfiguration calls (e.g. resolving every image in a gallery at once), each call's append writes WithImageConfiguration into the same backing-array slot, so one image's configuration stomps a sibling's and the loser resolves against the wrong package set - surfacing as "unable to lock packages to a consistent version" with a package blank on one arch. Clone the opts slice first, matching the existing pattern in NewMultiArch, so each call appends into its own backing array. Confirmed with go test -race, which previously reported a data race here.

…n concurrent resolves

LockImageConfigurationWithPackages appended WithImageConfiguration onto the caller's opts slice. When that slice has spare capacity and is shared across concurrent LockImageConfiguration calls (e.g. resolving every image in a gallery at once), each call's append writes WithImageConfiguration into the same backing-array slot, so one image's configuration stomps a sibling's and the loser resolves against the wrong package set - surfacing as "unable to lock packages to a consistent version" with a package blank on one arch. Clone the opts slice first, matching the existing pattern in NewMultiArch, so each call appends into its own backing array. Confirmed with go test -race, which previously reported a data race here.
@markusthoemmes
markusthoemmes marked this pull request as ready for review September 10, 2026 12:31
@markusthoemmes
markusthoemmes merged commit d83bd1c into chainguard-dev:main Sep 10, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants