ProtonMail / proton-bridge

Proton Mail Bridge application
GNU General Public License v3.0
1.16k stars 157 forks source link

ProtonMail Bridge: 32 bit version no longer builds #151

Closed grb43 closed 3 years ago

grb43 commented 3 years ago

Bridge v1.5.4 fails to build because of integer overflow errors in the go-RFC5322 module. v1.4.5 builds correctly. The build device is a 32 bit ARM QNAP, running headless Debian 10.

Expected Behavior

Build correctly per Bridge v1.4.5

Current Behavior

Bridge v1.5.4 fails to build

`admin@nas:~/sources/proton-bridge-br-1_5_4$ make build-nogui

go build -tags='pmapi_prod nogui' -ldflags '-X github.com/ProtonMail/proton-bridge/pkg/constants.Version=1.5.4-git -X github.com/ProtonMail/proton-bridge/pkg/constants.Revision=9d576beeb8 -X github.com/ProtonMail/proton-bridgepkg/constants.BuildTime=2021-01-12T09:07:59+1000' -o proton-bridge cmd/Desktop-Bridge/main.go

github.com/ProtonMail/go-rfc5322/parser ../../go/pkg/mod/github.com/!proton!mail/go-rfc5322@v0.2.1/parser/rfc5322_parser.go:2751: constant 4230534781 overflows int ../../go/pkg/mod/github.com/!proton!mail/go-rfc5322@v0.2.1/parser/rfc5322_parser.go:2775: constant 4230534781 overflows int ../../go/pkg/mod/github.com/!proton!mail/go-rfc5322@v0.2.1/parser/rfc5322_parser.go:6678: constant 2740715144 overflows int ../../go/pkg/mod/github.com/!proton!mail/go-rfc5322@v0.2.1/parser/rfc5322_parser.go:6678: constant 4294967167 overflows int ../../go/pkg/mod/github.com/!proton!mail/go-rfc5322@v0.2.1/parser/rfc5322_parser.go:6843: constant 3011247752 overflows int ../../go/pkg/mod/github.com/!proton!mail/go-rfc5322@v0.2.1/parser/rfc5322_parser.go:6843: constant 4294967167 overflows int ../../go/pkg/mod/github.com/!proton!mail/go-rfc5322@v0.2.1/parser/rfc5322_parser.go:11675: constant 4244674173 overflows int ../../go/pkg/mod/github.com/!proton!mail/go-rfc5322@v0.2.1/parser/rfc5322_parser.go:12100: constant 4292870143 overflows int make: *** [Makefile:78: build-nogui] Error 2 `

Possible Solution

v1.5.4 uses the new go-RFC5322 parser that was introduced after v1.4.5. I assume the new parser has some variables of type 'int' which are fine on 64 bit architecture, but overflow on a 32 bit device where they are only 32 bits wide. Possible solution (from a non programmer) to recast these variables to type 'int64'.

Context (Environment)

I retrieve mail from several PM mailboxes to an old, but reliable, NAS. This provides me with a local backup and assured off-line access. I use getmail, a simple mail retrieval agent, connected to PM Bridge to achieve this.

jameshoulahan commented 3 years ago

Hi! Yep, this is known. The code generated by ANTLR4 for the go-rfc5322 module only works under 64bit. This is a longstanding (dec 2018) issue with the ANTLR4 golang target and is tracked here. However, because that code is machine-generated (and is huge!), manually casting each of these variables is infeasible.

The last officially supported 32bit version of bridge was v1.2.5 (if i recall correctly). As such, we won't be investing any time into making bridge build for 32bit architecture. However, if ANTLR4 improves their go target such that it builds on 32bit architecture again, I'll gladly rerun the code generation to avoid the overflows.

mcprat commented 3 years ago

@jameshoulahan please put this information in README or BUILDS so one does not spend 4 hours setting up nothing...

jameshoulahan commented 3 years ago

@mpratt14 good idea, info will appear in BUILDS.md in the next release

jpmvferreira commented 3 years ago

Just for information considering that this issue is now closed, I'm planning to root my android phone and install some Linux based OS on it, considering that the processor architecture is ARM Cortex-A53, which according to Wikipedia is one of the first ones to support ARMv8 64 bit instruction set, will I be able to compile (or cross-compile in my computer) proton bridge for my device?

andrzejsza commented 3 years ago

you should be able to, although that's not something we'd recommend nor can help with. if you search around, I think someone from the community has tried that before.