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

Tests fail on 32-bit due to untyped integer overflows #1998

Closed
dswarbrick opened this issue Jan 30, 2023 · 1 comment · Fixed by #2026
Closed

Tests fail on 32-bit due to untyped integer overflows #1998

dswarbrick opened this issue Jan 30, 2023 · 1 comment · Fixed by #2026
Assignees
Labels
bug This issue is a bug. good-first-issue needs-triage This issue or PR still needs to be triaged.

Comments

@dswarbrick
Copy link
Contributor

Describe the bug

Tests fail to build on 32-bit due to the assumption that untyped integers are 64-bit.

Expected Behavior

Tests build successfully and pass.

Current Behavior

In main module:

# github.com/aws/aws-sdk-go-v2/aws/retry [github.com/aws/aws-sdk-go-v2/aws/retry.test]
aws/retry/jitter_backoff_test.go:41:16: cannot use 1 << 53 (untyped int constant 9007199254740992) as int value in struct literal (overflows)

And in service/internal/benchmark module:

# github.com/aws/aws-sdk-go-v2/service/internal/benchmark/dynamodb [github.com/aws/aws-sdk-go-v2/service/internal/benchmark/dynamodb.test]
dynamodb/customizations_test.go:41:22: cannot use 4158286593 (untyped int constant) as int value in struct literal (overflows)
dynamodb/customizations_test.go:42:22: cannot use 3095499784 (untyped int constant) as int value in struct literal (overflows)

Reproduction Steps

Run tests for 386 arch:

GOARCH=386 go test ./...

Possible Solution

For the main module, ExponentialJitterBackoff.BackoffDelay takes an unsigned int for the attempt. To avoid breaking an existing API, the test should either use a literal constant which won't overflow on 32-bit, or use platform-specific constants, e.g. Math.MaxInt

For the service/internal/benchmark module, the relevant testData struct members can simply be changed to int64, e.g.

 type testData struct {
    filename         string
-   respChecksum     int
-   respGzipChecksum int
+   respChecksum     int64
+   respGzipChecksum int64
 }

The use of strconv.Itoa in the test would also need to be changed to strconv.FormatInt, since the former takes an untyped int. However, this does beg the question of why larger-than-32-bit test values are being used in the X-Amz-Crc32 header. Is it not a 32-bit checksum?

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2 github.com/aws/smithy-go@v1.13.5
github.com/aws/aws-sdk-go-v2 github.com/google/go-cmp@v0.5.8
github.com/aws/aws-sdk-go-v2 github.com/jmespath/go-jmespath@v0.4.0
github.com/aws/smithy-go@v1.13.5 github.com/google/go-cmp@v0.5.8
github.com/aws/smithy-go@v1.13.5 github.com/jmespath/go-jmespath@v0.4.0
github.com/jmespath/go-jmespath@v0.4.0 github.com/jmespath/go-jmespath/internal/testify@v1.5.1
github.com/jmespath/go-jmespath/internal/testify@v1.5.1 github.com/davecgh/go-spew@v1.1.0
github.com/jmespath/go-jmespath/internal/testify@v1.5.1 github.com/pmezard/go-difflib@v1.0.0
github.com/jmespath/go-jmespath/internal/testify@v1.5.1 github.com/stretchr/objx@v0.1.0
github.com/jmespath/go-jmespath/internal/testify@v1.5.1 gopkg.in/yaml.v2@v2.2.8
gopkg.in/yaml.v2@v2.2.8 gopkg.in/check.v1@v0.0.0-20161208181325-20d25e280405

Compiler and Version used

go version go1.19.5 linux/amd64

Operating System and version

Debian sid

@dswarbrick dswarbrick added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 30, 2023
@wty-Bryant wty-Bryant linked a pull request Feb 16, 2023 that will close this issue
wty-Bryant added a commit that referenced this issue Feb 20, 2023
fix #1998 int overflow bug in 32 bit architecture
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. good-first-issue needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants