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: gcstoptheworld=2 doesn't work #53885

Closed
cherrymui opened this issue Jul 14, 2022 · 3 comments
Closed

runtime: gcstoptheworld=2 doesn't work #53885

cherrymui opened this issue Jul 14, 2022 · 3 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@cherrymui
Copy link
Member

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

tip (f71f3d1)

Does this issue reproduce with the latest release?

Yes, reproducible with Go 1.18.
Go 1.17 seems to work fine with no failure.

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

darwin/amd64

What did you do?

Running Go program with GODEBUG=gcstoptheworld=2.

What did you expect to see?

Runs successfully.

What did you see instead?

Crash in GC.

$ GODEBUG=gcstoptheworld=2 go tool compile hello.go 
fatal error: failed to set sweep barrier

goroutine 35 [running]:
runtime.throw({0x1949578?, 0xf738ad50e6127?})
	/Users/cherryyz/src/go/src/runtime/panic.go:1047 +0x5d fp=0xc0004d7538 sp=0xc0004d7508 pc=0x10369bd
runtime.gcMarkTermination()
	/Users/cherryyz/src/go/src/runtime/mgc.go:1056 +0xc6d fp=0xc0004d76f0 sp=0xc0004d7538 pc=0x101b3ad
runtime.gcMarkDone()
	/Users/cherryyz/src/go/src/runtime/mgc.go:918 +0x2ac fp=0xc0004d7750 sp=0xc0004d76f0 pc=0x101a4ac
runtime.gcBgMarkWorker()
	/Users/cherryyz/src/go/src/runtime/mgc.go:1367 +0x345 fp=0xc0004d77e0 sp=0xc0004d7750 pc=0x101b865
runtime.goexit()
	/Users/cherryyz/src/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0004d77e8 sp=0xc0004d77e0 pc=0x1069a81
created by runtime.gcBgMarkStartWorkers
	/Users/cherryyz/src/go/src/runtime/mgc.go:1159 +0x25

goroutine 1 [runnable]:
runtime.Gosched(...)
	/Users/cherryyz/src/go/src/runtime/proc.go:318
runtime.gcStart({0x212a108?, 0x1fcbc1b?, 0x10dc20?})
	/Users/cherryyz/src/go/src/runtime/mgc.go:749 +0x49c fp=0xc000422c90 sp=0xc000422c08 pc=0x1019dbc
runtime.mallocgc(0xb0, 0x18d7240, 0x1)
	/Users/cherryyz/src/go/src/runtime/malloc.go:1138 +0x80f fp=0xc000422d08 sp=0xc000422c90 pc=0x100d40f
runtime.makeslice(0x19242a0?, 0xc00010dc20?, 0x21334d0?)
	/Users/cherryyz/src/go/src/runtime/slice.go:103 +0x52 fp=0xc000422d30 sp=0xc000422d08 pc=0x104df72
cmd/compile/internal/ssa.(*regAllocState).regalloc(0xc00015a480, 0xc000412380)
	/Users/cherryyz/src/go/src/cmd/compile/internal/ssa/regalloc.go:1176 +0x90d fp=0xc0004238f0 sp=0xc000422d30 pc=0x137b4ed
cmd/compile/internal/ssa.regalloc(0xc000412380?)
	/Users/cherryyz/src/go/src/cmd/compile/internal/ssa/regalloc.go:148 +0x45 fp=0xc000423920 sp=0xc0004238f0 pc=0x13770e5
cmd/compile/internal/ssa.Compile(0xc000412380)
	/Users/cherryyz/src/go/src/cmd/compile/internal/ssa/compile.go:98 +0x9be fp=0xc000427598 sp=0xc000423920 pc=0x131333e
cmd/compile/internal/ssagen.buildssa(0xc000404140, 0x0)
	/Users/cherryyz/src/go/src/cmd/compile/internal/ssagen/ssa.go:574 +0x2007 fp=0xc000427910 sp=0xc000427598 pc=0x1680b27
cmd/compile/internal/ssagen.Compile(0xc000404140, 0xc0003d9f80?)
	/Users/cherryyz/src/go/src/cmd/compile/internal/ssagen/pgen.go:183 +0x4c fp=0xc0004279d8 sp=0xc000427910 pc=0x1677c8c
cmd/compile/internal/gc.compileFunctions.func4.1(0x1?)
	/Users/cherryyz/src/go/src/cmd/compile/internal/gc/compile.go:153 +0x3a fp=0xc000427a18 sp=0xc0004279d8 pc=0x1849e3a
cmd/compile/internal/gc.compileFunctions.func2(0x0?)
	/Users/cherryyz/src/go/src/cmd/compile/internal/gc/compile.go:125 +0x1e fp=0xc000427a30 sp=0xc000427a18 pc=0x1849a7e
cmd/compile/internal/gc.compileFunctions.func4({0xc000014520, 0x1, 0x1?})
	/Users/cherryyz/src/go/src/cmd/compile/internal/gc/compile.go:152 +0x53 fp=0xc000427a78 sp=0xc000427a30 pc=0x1849d33
cmd/compile/internal/gc.compileFunctions()
	/Users/cherryyz/src/go/src/cmd/compile/internal/gc/compile.go:163 +0x162 fp=0xc000427ad8 sp=0xc000427a78 pc=0x1849c02
cmd/compile/internal/gc.Main(0x1967670)
	/Users/cherryyz/src/go/src/cmd/compile/internal/gc/main.go:306 +0x1154 fp=0xc000427f20 sp=0xc000427ad8 pc=0x184b774
main.main()
	/Users/cherryyz/src/go/src/cmd/compile/main.go:57 +0xdd fp=0xc000427f80 sp=0xc000427f20 pc=0x187351d
runtime.main()
	/Users/cherryyz/src/go/src/runtime/proc.go:250 +0x212 fp=0xc000427fe0 sp=0xc000427f80 pc=0x10391d2
runtime.goexit()
	/Users/cherryyz/src/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000427fe8 sp=0xc000427fe0 pc=0x1069a81

... other goroutine stacks omitted ...

cc @mknyszek @golang/runtime

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 14, 2022
@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 14, 2022
@cherrymui cherrymui added this to the Backlog milestone Jul 14, 2022
@mknyszek mknyszek self-assigned this Jul 20, 2022
@mknyszek mknyszek modified the milestones: Backlog, Go1.20 Jul 20, 2022
@cherrymui cherrymui modified the milestones: Go1.20, Backlog Jan 10, 2023
@catenacyber
Copy link
Contributor

Getting the same error message trying to use gcstoptheworld=2 to debug #49075

@mknyszek
Copy link
Contributor

Looked into it briefly and I think I see the issue. The sweepLocker returned is invalid because there's nothing to sweep in this mode. The GC fully sweeps the heap before restarting the world with gcstoptheworld=2.

However, this isn't as simple as just ignoring the invalid sweepLocker, since there may still be stales spans in mcaches that gcSweep doesn't take care of. I think gcSweep needs to flush all the mcaches before the world restarts, and then the runtime should just skip all the mcache flushing sweep logic.

@gopherbot
Copy link

Change https://go.dev/cl/479517 mentions this issue: runtime: ignore invalid sweepLockers for non-concurrent sweep

@mknyszek mknyszek modified the milestones: Backlog, Go1.22 Jun 16, 2023
@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 4, 2023
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants