Repository navigation
Conversation
SemVerCmp subtracted (long) casts of unsigned ints. On 32-bit Kindles long is 32 bits, so (long) UINT_MAX is -1 and every version compared greater than the default max (SEMVER_MAX). Any dependency without an explicit "max" was then rejected with "Could not find artifact for <id> (0.0.0 - 4294967295...)", even when the artifact was indexed or already installed. Compare instead of subtracting, and add a SemVer test.
kylep33
force-pushed
the
fix-semvercmp-32bit
branch
from
November 12, 2026 08:28
612b45f to
845a99b
Compare
ThatHackerDudeFromCyberspace
added a commit
that referenced
this pull request
Nov 15, 2026
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.
Problem
On a 32-bit Kindle (kpm v0.2.4), installing any package whose dependencies have no explicit
"max"fails:This happens even though the dependency is in the index and installs fine on its own, and even after it's already installed.
Cause
SemVerCmpreturns(long) a.x - (long) b.x. On 32-bit ARM,longis 32 bits, so(long) UINT_MAXis-1. A missing"max"defaults toVERSION_MAX(UINT_MAX), soSemVerCmp(1.0.0, max)gives1 - (-1) = 2 > 0. The range check inInternal_ConstructGraphFromArtifactthen rejects every indexed and installed artifact.Fix
Compare the fields instead of subtracting them, returning -1/0/1. All callers only check the sign. The new
tests/kpm_semver_test.cincludesSemVerCmp(1.0.0, SEMVER_MAX) < 0. I confirmed that this assertion fails when the old function is compiled with a 32-bitlongand passes with the fix.Workaround until this is released: give each dependency an explicit range, e.g.
{"id": "foo", "min": [1, 0, 0], "max": [2, 0, 0]}.