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

Support 32-bit archs like ARM7 #125

Closed
wants to merge 2 commits into from
Closed

Support 32-bit archs like ARM7 #125

wants to merge 2 commits into from

Conversation

dhui
Copy link

@dhui dhui commented Jul 28, 2020

Before this change, builds of v1.8.0 failed:

$ GOARCH=arm GOARM=7 go build ./...
# github.com/neo4j/neo4j-go-driver/neo4j/internal/packstream
neo4j/internal/packstream/packer.go:130:10: constant 4294967295 overflows int
neo4j/internal/packstream/packer.go:167:9: constant 4294967296 overflows int

This PR fixes that

Copy link
Contributor

@2hdddg 2hdddg left a comment

Choose a reason for hiding this comment

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

Thanks for your pull request and good that you found this! We will look into compiling for 32 bits in our build pipelines to find these kind of errors early on!
You need to sign our CLA before we can merge your changes.

@@ -127,7 +127,7 @@ func (p *Packer) writeListHeader(l int, shortOffset, longOffset byte) error {
hdr = hdr[:1+2]
hdr[0] = longOffset + 1
binary.BigEndian.PutUint16(hdr[1:], uint16(l))
case l < math.MaxUint32:
case uint32(l) < uint32(math.MaxUint32):
Copy link
Contributor

Choose a reason for hiding this comment

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

uint32(l) will truncate l to fit into uint32 and the comparison will always succeed
l needs to be int64 instead of int to compile and work properly on 32/64 bits systems.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! Didn't know that int64 would work on a 32-bit system

@@ -164,7 +164,7 @@ func (p *Packer) writeBytes(b []byte) error {
hdr = hdr[:1+2]
hdr[0] = 0xcd
binary.BigEndian.PutUint16(hdr[1:], uint16(l))
case l < 0x100000000:
case uint32(l) <= uint32(0xffffffff):
Copy link
Contributor

Choose a reason for hiding this comment

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

See above

* cast to int64 since values will overflow an int32
* int64 will work on a 32-bit system: https://groups.google.com/forum/#!topic/golang-nuts/mtnn-01Dh_I
@dhui
Copy link
Author

dhui commented Jul 31, 2020

We will look into compiling for 32 bits in our build pipelines to find these kind of errors early on!

This would be great to prevent regressions!

You need to sign our CLA before we can merge your changes.

I'd rather not sign the CLA and don't need the attribution but getting this issue fixed would be nice. This code change is trivial so you're welcome to take it and make it your own.

@2hdddg
Copy link
Contributor

2hdddg commented Aug 3, 2020

Fixed in another PR

@2hdddg 2hdddg closed this Aug 3, 2020
@dhui dhui deleted the arm7 branch August 4, 2020 01:02
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