Skip to content

fix: prevent index out of range panic on 32-bit platforms#415

Merged
9seconds merged 1 commit into9seconds:masterfrom
dolonet:fix/event-stream-32bit-index-panic
Mar 29, 2026
Merged

fix: prevent index out of range panic on 32-bit platforms#415
9seconds merged 1 commit into9seconds:masterfrom
dolonet:fix/event-stream-32bit-index-panic

Conversation

@dolonet
Copy link
Copy Markdown
Contributor

@dolonet dolonet commented Mar 28, 2026

On 32-bit architectures (e.g. ARM7), int is 32 bits wide. Casting a uint32 hash value to int can overflow, producing a negative number. Go's modulo operator preserves the sign, so the channel index can become -1, causing a panic:

index out of range [-1]

This happens roughly 50% of the time — whenever the xxhash result exceeds math.MaxInt32.

The fix performs the modulo in uint32 space before indexing the slice, ensuring the result is always non-negative.

Fixes #413

On 32-bit architectures (e.g. ARM7), int is 32 bits wide.
Casting a uint32 hash value to int can overflow, producing a
negative number. Go's modulo operator preserves the sign, so
the channel index can become -1, causing a panic.

Perform the modulo in uint32 space before indexing to ensure
the result is always non-negative.

Fixes 9seconds#413
@dolonet dolonet mentioned this pull request Mar 28, 2026
@9seconds 9seconds merged commit 9917f61 into 9seconds:master Mar 29, 2026
5 checks passed
@9seconds
Copy link
Copy Markdown
Owner

Кажется, новый релиз будет состоять в основном из вашей работы :)

@dolonet
Copy link
Copy Markdown
Contributor Author

dolonet commented Mar 29, 2026

Кажется, новый релиз будет состоять в основном из вашей работы :)

Опенсорс засасывает, особенно в выходные :)

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.

proxy.domain-fronting

2 participants