fix(Platform): make arm64 nil-variant and v8 hash identically#764
Open
Otoru wants to merge 1 commit into
Open
Conversation
Platform.== treats arm64 with nil variant as equal to arm64/v8, but
hash(into:) used description which serializes them differently
("linux/arm64" vs "linux/arm64/v8"). This violated the Hashable
contract and caused Set/Dictionary lookups to miss entries when one
platform was decoded from JSON (no variant field) and another was
created via Platform(from:) or Platform.current (which set variant=v8).
The practical consequence was inconsistent platform-string normalization
across stages of a single container build, which could cause
COPY --from=<stage> to fail to resolve the source stage.
Fix hash(into:) to normalize arm64 nil variant to "v8" before hashing,
matching the existing == behavior.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Platform.==treatsarm64withnilvariant as equal toarm64/v8, buthash(into:)useddescriptionwhich serializes them differently (linux/arm64vslinux/arm64/v8). This violates theHashablecontract — equal values must produce the same hash.Root cause
This mismatch caused
Set<Platform>andDictionary<Platform, ...>lookups to silently miss entries when one platform was decoded from JSON (novariantfield in the manifest) and another was created viaPlatform(from:)orPlatform.current(which both setvariant = "v8").Practical consequence
In
apple/container, this manifests as inconsistent platform-string normalization across stages of a singlecontainer build— some stages loglinux/arm64, otherslinux/arm64/v8— which can causeCOPY --from=<stage>to fail to resolve the source stage under concurrent builds. See apple/container#1542.Fix
hash(into:)now normalizesarm64withnilvariant to"v8"before hashing, matching the existing==behavior.