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: stoplockedm: inconsistent locking #46524

Closed
prattmic opened this issue Jun 2, 2021 · 2 comments
Closed

runtime: stoplockedm: inconsistent locking #46524

prattmic opened this issue Jun 2, 2021 · 2 comments
Assignees
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@prattmic
Copy link
Member

prattmic commented Jun 2, 2021

2021-04-16T21:50:38-9481789/freebsd-arm-paulzhol
2021-04-09T12:56:04-519f223/netbsd-amd64-9_0

fatal error: stoplockedm: inconsistent locking

runtime stack:
runtime.throw(0x5a78b0, 0x21)
        /tmp/workdir/go/src/runtime/panic.go:1193 +0x74 fp=0x7384fbbffeb0 sp=0x7384fbbffe80 pc=0x43ee94
runtime.stoplockedm()
        /tmp/workdir/go/src/runtime/proc.go:2479 +0x2b0 fp=0x7384fbbfff00 sp=0x7384fbbffeb0 pc=0x446970
runtime.exitsyscall0(0xc00019a300)
        /tmp/workdir/go/src/runtime/proc.go:3884 +0x179 fp=0x7384fbbfff30 sp=0x7384fbbfff00 pc=0x44a599
runtime.mcall(0x400000)
        /tmp/workdir/go/src/runtime/asm_amd64.s:341 +0x5a fp=0x7384fbbfff40 sp=0x7384fbbfff30 pc=0x471dfa

goroutine 1 [chan receive]:
runtime.gopark(0x5ae208, 0xc000198368, 0x170e, 0x2)
        /tmp/workdir/go/src/runtime/proc.go:334 +0x105 fp=0xc000098b48 sp=0xc000098b28 pc=0x441e65
runtime.chanrecv(0xc000198310, 0xc000098c4f, 0xc000000101, 0x4d85cb)
        /tmp/workdir/go/src/runtime/chan.go:576 +0x5f7 fp=0xc000098bd8 sp=0xc000098b48 pc=0x40d557
runtime.chanrecv1(0xc000198310, 0xc000098c4f)
        /tmp/workdir/go/src/runtime/chan.go:439 +0x2b fp=0xc000098c08 sp=0xc000098bd8 pc=0x40cf4b
testing.(*T).Run(0xc0000bec00, 0x5a1c03, 0xc, 0x5ab7b0, 0x488201)
        /tmp/workdir/go/src/testing/testing.go:1281 +0x3d2 fp=0xc000098ca0 sp=0xc000098c08 pc=0x4d85f2
testing.runTests.func1(0xc00019a000)
        /tmp/workdir/go/src/testing/testing.go:1553 +0x85 fp=0xc000098cf0 sp=0xc000098ca0 pc=0x4d9f65
testing.tRunner(0xc00019a000, 0xc00007dde0)
        /tmp/workdir/go/src/testing/testing.go:1235 +0x102 fp=0xc000098d40 sp=0xc000098cf0 pc=0x4d7862
testing.runTests(0xc000194000, 0x8ab7e0, 0x59, 0x59, 0xc0143355ed0a8eb6, 0x8bb3a3bba2, 0x8c2fa0, 0x0)
        /tmp/workdir/go/src/testing/testing.go:1551 +0x450 fp=0xc000098e10 sp=0xc000098d40 pc=0x4d9e10
testing.(*M).Run(0xc00018e000, 0x0)
        /tmp/workdir/go/src/testing/testing.go:1459 +0x25b fp=0xc000098f20 sp=0xc000098e10 pc=0x4d8abb
main.main()
        _testmain.go:225 +0x165 fp=0xc000098f88 sp=0xc000098f20 pc=0x55d3a5
runtime.main()
        /tmp/workdir/go/src/runtime/proc.go:223 +0x248 fp=0xc000098fe0 sp=0xc000098f88 pc=0x441a08
runtime.goexit()
        /tmp/workdir/go/src/runtime/asm_amd64.s:1500 +0x1 fp=0xc000098fe8 sp=0xc000098fe0 pc=0x473f81

An internal test triggered this same crash and a bisect identified http://golang.org/cl/291329 as the cause. Likely the assertion in the comment is not always true, but I'll need to look more closely.

cc @mknyszek @ianlancetaylor

@prattmic prattmic added this to the Go1.17 milestone Jun 2, 2021
@prattmic prattmic self-assigned this Jun 2, 2021
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 2, 2021
@prattmic
Copy link
Member Author

prattmic commented Jun 2, 2021

The problem is that earlier in exitsyscall0 we put gp on the global runq, allowing us to race reading gp.lockedm with another M running gp (which wasn't locked) and having it call lockOSThread, thus setting gp.lockedm.

CL forthcoming.

@gopherbot
Copy link

Change https://golang.org/cl/324350 mentions this issue: runtime: avoid gp.lockedm race in exitsyscall0

@golang golang locked and limited conversation to collaborators Jun 3, 2022
@prattmic prattmic self-assigned this Jun 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants