Skip to content

Conversation

@nemith
Copy link
Owner

@nemith nemith commented Jan 9, 2026

The chunkedWriter correctly works with the max int size on 32bit platforms but the read side was still assuming math.MaxUint32. Since len(p) is weirdly signed this doesn't work so cap it at Math.MaxInt the same way we do for the writer.

I really wish Go used usize for things like this cause this is just a pain in the ass.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the chunkedReader implementation where it was using math.MaxUint32 instead of math.MaxInt to cap buffer sizes on 32-bit platforms. Since Go slice lengths are signed integers (type int), this caused issues on 32-bit systems where math.MaxUint32 exceeds the maximum value of int.

Key changes:

  • Moved maxChunkSize constant from chunkedWriter.Write method to package-level scope for reuse
  • Updated chunkedReader.Read to use maxChunkSize instead of math.MaxUint32, ensuring consistency with the writer and proper handling on 32-bit platforms

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 143 to 145
// RFC 6242 allows up to MaxUint32 (4294967295), but on 32-bit systems
// slice lengths are limited to MaxInt32. We use the minimum of both
// to ensure compatibility across all architectures.
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The comment mentions "MaxInt32" but should refer to "MaxInt" for accuracy. On 32-bit systems, math.MaxInt equals math.MaxInt32, but on 64-bit systems, math.MaxInt equals math.MaxInt64. The comment should be updated to reflect that slice lengths are limited to math.MaxInt (not specifically MaxInt32).

Suggested change
// RFC 6242 allows up to MaxUint32 (4294967295), but on 32-bit systems
// slice lengths are limited to MaxInt32. We use the minimum of both
// to ensure compatibility across all architectures.
// RFC 6242 allows up to MaxUint32 (4294967295), but slice lengths are
// limited to math.MaxInt. We use the minimum of both to ensure
// compatibility across all architectures.

Copilot uses AI. Check for mistakes.
@nemith nemith force-pushed the brb/push-pkyokursztlx branch from 1fc2a9d to 5c5e121 Compare January 9, 2026 00:50
@nemith nemith merged commit 146635a into main Jan 9, 2026
6 checks passed
@nemith nemith deleted the brb/push-pkyokursztlx branch January 9, 2026 00:51
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