Skip to content

Inconsistent strconv.Atoi behavior for 32bit release, lead to error or data corruption. #20161

Closed
@wxiaoguang

Description

@wxiaoguang

strconv.Atoi has different behavior:

$ GOARCH=386 go run test-int.go
2147483647 (0x80bee40,0x8c8e000)

$ GOARCH=amd64 go run test-int.go
4294967295 (0x0,0x0)

$ cat test-int.go
package main

import "strconv"

func main() {
	println(strconv.Atoi("4294967295"))
}

For example, in XORM:

image

A user has reported that Gitea 1.17 failed with error:

...
2022/06/28 11:47:32 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds
2022/06/28 11:47:35 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #9/10...
2022/06/28 11:47:35 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #9/10 failed. Error: sync database struct error: strconv.Atoi: parsing "4294967295": value out of range
2022/06/28 11:47:35 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds
2022/06/28 11:47:38 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #10/10...
2022/06/28 11:47:38 routers/init.go:68:mustInitCtx() [F] code.gitea.io/gitea/routers/common.InitDBEngine(ctx) failed: sync database struct error: strconv.Atoi: parsing "4294967295": value out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/criticalThis issue should be fixed ASAP. If it is a PR, the PR should be merged ASAPtype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions