Skip to content
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

runtime: failed MSpanList_Remove, integer divide by zero #31379

Closed
rename2 opened this issue Apr 10, 2019 · 3 comments
Closed

runtime: failed MSpanList_Remove, integer divide by zero #31379

rename2 opened this issue Apr 10, 2019 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@rename2
Copy link

rename2 commented Apr 10, 2019

What version of Go are you using (go version)?

$ go1.11.5 linux/amd64
(compile to linux/386)

Does this issue reproduce with the latest release?

Don't know. Have not upgrade to latest release.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
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-build342362144=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Developing a program that periodically executing scripts to monitor system status.

What did you expect to see?

No crashes.

What did you see instead?

Random crashes.

fatal error: integer divide by zero
runtime: failed MSpanList_Remove span.npages=0 span=0xe71acf44 prev=0x0 span.list=0x0 list=0x8b0d08c
fatal error: MSpanList_Remove
fatal error: integer divide by zero

runtime stack:
runtime.throw(0x866beca, 0x16)
	/usr/local/go/src/runtime/panic.go:608 +0x6a
runtime.panicCheckMalloc(0x8734da0, 0x8affe00)
	/usr/local/go/src/runtime/panic.go:20 +0x5e
runtime.panicdivide()
	/usr/local/go/src/runtime/panic.go:60 +0x2d
runtime.(*mcentral).cacheSpan(0x8b0de90, 0x1)
	/usr/local/go/src/runtime/mcentral.go:120 +0x453
runtime.(*mcache).refill(0xf7793000, 0xae2410d)
	/usr/local/go/src/runtime/mcache.go:122 +0x8dgo 
runtime.(*mcache).nextFree.func1()
	/usr/local/go/src/runtime/malloc.go:749 +0x28
runtime.systemstack(0xae241c0)
	/usr/local/go/src/runtime/asm_386.s:396 +0x53
runtime.mstart()
	/usr/local/go/src/runtime/proc.go:1229

goroutine 1658402 [running]:
runtime.systemstack_switch()
	/usr/local/go/src/runtime/asm_386.s:357 fp=0xade2cb4 sp=0xade2cb0 pc=0x80989b0
runtime.(*mcache).nextFree(0xf7793000, 0xd, 0x0, 0x0, 0x0)
	/usr/local/go/src/runtime/malloc.go:748 +0xa5 fp=0xade2cdc sp=0xade2cb4 pc=0x8051625
runtime.mallocgc(0x50, 0x86440a0, 0x1, 0xc0000000)
	/usr/local/go/src/runtime/malloc.go:903 +0x608 fp=0xade2d30 sp=0xade2cdc pc=0x8051dc8
runtime.newobject(0x86440a0, 0xb602b01)
	/usr/local/go/src/runtime/malloc.go:1032 +0x2c fp=0xade2d44 sp=0xade2d30 pc=0x805209c
os.(*Process).wait(0xb602b40, 0xadd6188, 0xf5aa500, 0xadd6190)
	/usr/local/go/src/os/exec_unix.go:37 +0x63 fp=0xade2d7c sp=0xade2d44 pc=0x8100873
os.(*Process).Wait(0xb602b40, 0x86923e0, 0x86923e4, 0x86923dc)
	/usr/local/go/src/os/exec.go:125 +0x21 fp=0xade2d90 sp=0xade2d7c pc=0x80fff61
os/exec.(*Cmd).Wait(0xe29a0b0, 0x0, 0x0)
	/usr/local/go/src/os/exec/exec.go:465 +0x43 fp=0xade2dc8 sp=0xade2d90 pc=0x8349843
os/exec.(*Cmd).Run(0xe29a0b0, 0xacee000, 0xb32964c)
....

runtime stack:
runtime.throw(0x8666be3, 0x10)
	/usr/local/go/src/runtime/panic.go:608 +0x6a
runtime.(*mSpanList).remove(0x8b0d08c, 0xe71acf44)
	/usr/local/go/src/runtime/mheap.go:1214 +0x153
runtime.(*mheap).allocSpanLocked(0x8b0d080, 0x1, 0x8b1db88, 0x0)
	/usr/local/go/src/runtime/mheap.go:841 +0x5f
runtime.(*mheap).alloc_m(0x8b0d080, 0x1, 0x47, 0xb2670a0)
	/usr/local/go/src/runtime/mheap.go:692 +0x115
runtime.(*mheap).alloc.func1()
	/usr/local/go/src/runtime/mheap.go:759 +0x3e
runtime.(*mheap).alloc(0x8b0d080, 0x1, 0x10047, 0x28)
	/usr/local/go/src/runtime/mheap.go:758 +0x6c
runtime.(*mcentral).grow(0x8b0ed10, 0x0)
	/usr/local/go/src/runtime/mcentral.go:232 +0x72
runtime.(*mcentral).cacheSpan(0x8b0ed10, 0xb5ec460)
	/usr/local/go/src/runtime/mcentral.go:106 +0x30b
runtime.(*mcache).refill(0xf7795f40, 0xac00747)
	/usr/local/go/src/runtime/mcache.go:122 +0x8d
runtime.(*mcache).nextFree.func1()
	/usr/local/go/src/runtime/malloc.go:749 +0x28
runtime.systemstack(0xac007e0)
	/usr/local/go/src/runtime/asm_386.s:396 +0x53
runtime.mstart()
	/usr/local/go/src/runtime/proc.go:1229	

runtime stack:
runtime.throw(0x866beca, 0x16)
	/usr/local/go/src/runtime/panic.go:608 +0x6a
runtime.panicCheckMalloc(0x8734da0, 0x8affe00)
	/usr/local/go/src/runtime/panic.go:20 +0x5e
runtime.panicdivide()
	/usr/local/go/src/runtime/panic.go:60 +0x2d
runtime.(*mcentral).cacheSpan(0x8b0e010, 0xf779de8c)
	/usr/local/go/src/runtime/mcentral.go:120 +0x453
runtime.(*mcache).refill(0xf77951c0, 0xb632513)
	/usr/local/go/src/runtime/mcache.go:122 +0x8d
runtime.(*mcache).nextFree.func1()
	/usr/local/go/src/runtime/malloc.go:749 +0x28
runtime.systemstack(0xaeff500)
	/usr/local/go/src/runtime/asm_386.s:396 +0x53
runtime.mstart()
	/usr/local/go/src/runtime/proc.go:1229
@ALTree
Copy link
Member

ALTree commented Apr 10, 2019

Thanks for the report.

This will be hard to debug unless you provide a reproducer.

Usual questions:

  • Does your program use cgo?
  • Does the race detector barks if you run your program with the -race flag (i.e. go run -flag main.go)?

@ALTree ALTree added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 10, 2019
@rename2
Copy link
Author

rename2 commented Apr 17, 2019

Thanks for the report.

This will be hard to debug unless you provide a reproducer.

Usual questions:

  • Does your program use cgo?
  • Does the race detector barks if you run your program with the -race flag (i.e. go run -flag main.go)?

1 My program calls library pty(github.com/kr/pty) which use cgo.
2 Yes, race detector shows serveral problems. Is it related to this runtime error?

@ALTree
Copy link
Member

ALTree commented Apr 17, 2019

Yes. A program containing a data race is not a valid Go program; moreover data races can corrupt internal runtime data structures, which can lead to panics like the one you're seeing.

To fix the issue (and make your program a valid one) you'll need to fix every data race in your code.

Closing here, since this is not a Go bug.

@ALTree ALTree closed this as completed Apr 17, 2019
@golang golang locked and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants