-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
There was a problem hiding this 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.
neo4j/internal/packstream/packer.go
Outdated
@@ -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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
neo4j/internal/packstream/packer.go
Outdated
@@ -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): |
There was a problem hiding this comment.
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
This would be great to prevent regressions!
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. |
Fixed in another PR |
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