-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
What version of Go are you using (go version)?
$ go version go version go1.15.2 linux/amd64
Does this issue reproduce with the latest release?
yes.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/scop/.cache/go-build" GOENV="/home/scop/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/scop/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/scop/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/lib/go-1.15" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib/go-1.15/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build861159730=/tmp/go-build -gno-record-gcc-switches"
What did you do?
package main
import (
"math/big"
)
func main() {
data := "9.9999999999999999999990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
new(big.Rat).SetString(data)
}https://play.golang.org/p/NNhU-zb5KG8
What did you expect to see?
This should not panic.
Based on SetString documentation, If the operation failed, the value of z should be undefined and the returned value is nil.
What did you see instead?
panic: impossible
goroutine 1 [running]:
math/big.nat.divRecursiveStep(0xc0000d01c0, 0x33, 0x37, 0xc0000ea500, 0x96, 0x9c, 0xc0000ec000, 0x64, 0x1c9, 0x0, ...)
/usr/local/go-faketime/src/math/big/nat.go:951 +0x139a
math/big.nat.divRecursive(0xc0000d01c0, 0x33, 0x37, 0xc0000ea500, 0x97, 0x9c, 0xc0000ec000, 0x64, 0x1c9)
/usr/local/go-faketime/src/math/big/nat.go:828 +0x17e
math/big.nat.divLarge(0xc0000b20c0, 0x2, 0x6, 0xc0000ea500, 0x97, 0x9c, 0xc0000e3400, 0x96, 0x9b, 0xc0000e3900, ...)
/usr/local/go-faketime/src/math/big/nat.go:727 +0x412
math/big.nat.div(0xc0000b20c0, 0x2, 0x6, 0xc0000ea500, 0x97, 0x9c, 0xc0000e3400, 0x96, 0x9b, 0xc0000e3900, ...)
/usr/local/go-faketime/src/math/big/nat.go:672 +0x410
math/big.(*Int).QuoRem(0xc000093ca0, 0xc000093d20, 0xc000093d00, 0xc000093c80, 0xc000093ca0, 0xc000093c80)
/usr/local/go-faketime/src/math/big/int.go:239 +0xbf
math/big.euclidUpdate(0xc000093d20, 0xc000093d00, 0x0, 0x0, 0xc000093ca0, 0xc000093c80, 0xc000093c60, 0xc000093c40, 0xc0000c6200)
/usr/local/go-faketime/src/math/big/int.go:648 +0x67
math/big.(*Int).lehmerGCD(0xc000093df0, 0x0, 0x0, 0xc000093f38, 0xc000093f58, 0x168)
/usr/local/go-faketime/src/math/big/int.go:718 +0x49c
math/big.(*Rat).norm(0xc000093f38, 0x6a)
/usr/local/go-faketime/src/math/big/rat.go:445 +0x151
math/big.(*Rat).SetString(0xc00009ef38, 0x4dcfe3, 0xb5e, 0x563c40, 0xc000032778)
/usr/local/go-faketime/src/math/big/ratconv.go:198 +0x6c7
main.main()
/tmp/sandbox085893432/prog.go:9 +0x57