Build error: math.MaxUint32 overflows int
Closed this issue · 4 comments
Go version:
go version go1.19.2 linux/arm
Build architecture:
armv7l
Problem:
I'm attempting to build go-sbot
which relies on go-muxrpc
(see ssbc/go-ssb#180 for details). The build fails with the following error message:
../go/pkg/mod/github.com/ssbc/go-muxrpc/v2@v2.0.14-0.20221020091224-b09bdf60812f/codec/writer.go:27:15: math.MaxUint32 (untyped int constant 4294967295) overflows int
Possible fix:
I believe this can be solved with the following change to codec/writer.go:27:15
:
// cast `bodyLen` to uint
if uint(bodyLen) > math.MaxUint32 {
I tried this fix on a fork and it passes the tests. I wanted to retry the build of go-sbot
with this change but I am utterly failing (no Go experience; don't know how to change the module dependency to pull from my fork).
Amazingggg, try this in the go-ssb
go.mod
which assumes a locally hacked copy of go-muxrpc
in ../
🤞
diff --git a/go.mod b/go.mod
index c4d475f..51c2757 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,8 @@ module github.com/ssbc/go-ssb
go 1.13
+replace github.com/ssbc/go-muxrpc/v2 => ./../go-muxrpc
+
require (
filippo.io/edwards25519 v1.0.0
github.com/RoaringBitmap/roaring v1.2.1
Then the new go-sbot
build should pull in the local go-muxrpc
copy.
I tried this fix on a fork and it passes the tests.
Hmmmm I'm seeing tests fail locally 🤔
(go test -v ./...
(requires running npm ci
beforehand), more specifically go test -v ./codec -run TestWriteTooLarge
)
These two seem to point to a deeper problem, the handling of int
on different archs:
I think what needs to be done is override NewWriter
to return a WritePacket
which is appropriate for the architecture... and WritePacket
may need to be defined in a separate writer.go
/writer_32bit.go
file which has appropriate build tags (e.g. // go:build 386 arm armbe mips mipsle ppc s390 sparc
) to choose at compile time... seems quite involved but basically the approach as highlighted in golang/go#33388...
If you can confirm that this change gets you a working go-muxrpc
on a pi zero then I can take a run at the PR for the fix?
Also if you wanna dive into doing that, please don't let me stop you 😆
Ah shoot, thanks for checking the tests and providing additional details. I only tried the basic go test
on my Pi Zero and it passed. I should have known such a simple fix was too good to be true.
If you can confirm that this change gets you a working go-muxrpc on a pi zero then I can take a run at the PR for the fix?
Confirmed! It's working! go-sbot compiled successfully using the updated go-muxrpc and it has now been running for 45 minutes without a crash. Message publishing is working. I am running legacy replication for the moment. I just followed my main ID and replication is underway.
If you'd like to take a run at a fix then I will cheer you on! Otherwise I can attempt to follow your breadcrumbs and work on a fix during the week.
Confirmed! It's working!
Spectacular!
If you'd like to take a run at a fix
Hoping that #15 might do it after all 🙏