Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: int64 math overflows possible on 32-bit architectures #435

Merged
merged 3 commits into from
Apr 24, 2021

Conversation

puellanivis
Copy link
Collaborator

Investigating #433 I tracked it down to a situation where an overflow in 32-bit architectures can result in a calculation of concurrency = 0. With zero concurrency… the wg.Wait() returns immediately and no work is done.

The solution is to check if concurrency is less than one, and if it is, then use max concurrency, as we overflowed an int32, so it should use max concurrency.

@puellanivis
Copy link
Collaborator Author

client.go Outdated Show resolved Hide resolved
Comment on lines +1655 to +1657
if remain < 0 {
remain = math.MaxInt64
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was added from discussion in #426 where we want to default to maximum concurrency when we have a Size reported as less than 0.

@drakkan
Copy link
Collaborator

drakkan commented Apr 24, 2021

Thank you

@drakkan drakkan merged commit 2992404 into master Apr 24, 2021
@drakkan drakkan mentioned this pull request Jun 12, 2021
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