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: "lock ordering problem" between fin and wbufSpans #41021

Closed
bcmills opened this issue Aug 25, 2020 · 2 comments
Closed

runtime: "lock ordering problem" between fin and wbufSpans #41021

bcmills opened this issue Aug 25, 2020 · 2 comments

Comments

@bcmills
Copy link
Member

@bcmills bcmills commented Aug 25, 2020

2020-08-24T21:08:46-95df156/linux-amd64-staticlockranking

##### ../misc/cgo/errors
--- FAIL: TestPointerChecks (1.07s)
    --- FAIL: TestPointerChecks/finalizer (0.04s)
        ptr_test.go:620: 111337  ======
            0 : fin 18 0x7dc400
            1 : wbufSpans 37 0x7aac70
            fatal error: lock ordering problem
            
            runtime stack:
            runtime.throw(0x4f7309, 0x15)
            	/workdir/go/src/runtime/panic.go:1116 +0x72
            runtime.checkRanks(0xc000082780, 0x12, 0x25)
            	/workdir/go/src/runtime/lockrank_on.go:141 +0x2a9
            runtime.lockWithRankMayAcquire.func1()
            	/workdir/go/src/runtime/lockrank_on.go:211 +0xac
            runtime.lockWithRankMayAcquire(0x7aac70, 0x25)
            	/workdir/go/src/runtime/lockrank_on.go:200 +0x6f
            runtime.getempty(0x7fd9e1a46e38)
            	/workdir/go/src/runtime/mgcwork.go:432 +0x4f
            runtime.(*gcWork).init(0xc000024e98)
            	/workdir/go/src/runtime/mgcwork.go:117 +0x25
            runtime.(*gcWork).putBatch(0xc000024e98, 0xc000024f58, 0x1, 0x200)
            	/workdir/go/src/runtime/mgcwork.go:245 +0x19f
            runtime.wbBufFlush1(0xc000023800)
            	/workdir/go/src/runtime/mwbbuf.go:315 +0x237
            runtime.wbBufFlush.func1()
            	/workdir/go/src/runtime/mwbbuf.go:218 +0x3a
            runtime.systemstack(0x0)
            	/workdir/go/src/runtime/asm_amd64.s:370 +0x66
            runtime.mstart()
            	/workdir/go/src/runtime/proc.go:1116
            
            goroutine 18 [running]:
            runtime.systemstack_switch()
            	/workdir/go/src/runtime/asm_amd64.s:330 fp=0xc00002a6a0 sp=0xc00002a698 pc=0x466ce0
            runtime.wbBufFlush(0x7a9eb8, 0xc000106300)
            	/workdir/go/src/runtime/mwbbuf.go:206 +0x66 fp=0xc00002a6d0 sp=0xc00002a6a0 pc=0x431b46
            runtime.gcWriteBarrier(0x7dc400, 0x12, 0xc00000c000, 0x2000000020, 0xc00002a7d0, 0x438c85, 0x20, 0x20, 0x20, 0x0, ...)
            	/workdir/go/src/runtime/asm_amd64.s:1461 +0xae fp=0xc00002a758 sp=0xc00002a6d0 pc=0x468b6e
            runtime.runfinq()
            	/workdir/go/src/runtime/mfinal.go:173 +0xd1 fp=0xc00002a7e0 sp=0xc00002a758 pc=0x41a771
            runtime.goexit()
            	/workdir/go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc00002a7e8 sp=0xc00002a7e0 pc=0x468aa1
            created by runtime.createfing
            	/workdir/go/src/runtime/mfinal.go:156 +0x65
            111337  ======
            0 : fin 18 0x7dc400
            1 : wbufSpans 37 0x7aac70
            2 : allg 11 0x7dc380
            fatal error: lock ordering problem
            panic during panic
            
            runtime stack:
            runtime.throw(0x4f7309, 0x15)
            	/workdir/go/src/runtime/panic.go:1116 +0x72
            runtime.checkRanks(0xc000082780, 0x25, 0xb)
            	/workdir/go/src/runtime/lockrank_on.go:141 +0x2a9
            runtime.lockWithRank.func1()
            	/workdir/go/src/runtime/lockrank_on.go:83 +0xbc
            runtime.lockWithRank(0x7dc380, 0xb)
            	/workdir/go/src/runtime/lockrank_on.go:72 +0x8e
            runtime.lock(...)
            	/workdir/go/src/runtime/lock_futex.go:47
            runtime.tracebackothers(0xc000082780)
            	/workdir/go/src/runtime/traceback.go:917 +0x93
            runtime.dopanic_m(0xc000082780, 0x436492, 0x7fd9e1a46cb0, 0x1)
            	/workdir/go/src/runtime/panic.go:1316 +0x2c9
            runtime.fatalthrow.func1()
            	/workdir/go/src/runtime/panic.go:1171 +0x5f
            runtime.fatalthrow()
            	/workdir/go/src/runtime/panic.go:1168 +0x57
            runtime.throw(0x4f7309, 0x15)
            	/workdir/go/src/runtime/panic.go:1116 +0x72
            runtime.checkRanks(0xc000082780, 0x12, 0x25)
            	/workdir/go/src/runtime/lockrank_on.go:141 +0x2a9
            runtime.lockWithRankMayAcquire.func1()
            	/workdir/go/src/runtime/lockrank_on.go:211 +0xac
            runtime.lockWithRankMayAcquire(0x7aac70, 0x25)
            	/workdir/go/src/runtime/lockrank_on.go:200 +0x6f
            runtime.getempty(0x7fd9e1a46e38)
            	/workdir/go/src/runtime/mgcwork.go:432 +0x4f
            runtime.(*gcWork).init(0xc000024e98)
            	/workdir/go/src/runtime/mgcwork.go:117 +0x25
            runtime.(*gcWork).putBatch(0xc000024e98, 0xc000024f58, 0x1, 0x200)
            	/workdir/go/src/runtime/mgcwork.go:245 +0x19f
            runtime.wbBufFlush1(0xc000023800)
            	/workdir/go/src/runtime/mwbbuf.go:315 +0x237
            runtime.wbBufFlush.func1()
            	/workdir/go/src/runtime/mwbbuf.go:218 +0x3a
            runtime.systemstack(0x0)
            	/workdir/go/src/runtime/asm_amd64.s:370 +0x66
            runtime.mstart()
            	/workdir/go/src/runtime/proc.go:1116
        ptr_test.go:621: failed unexpectedly with expensive checks: exit status 2
FAIL

CC @danscales @aclements @prattmic

@prattmic
Copy link
Member

@prattmic prattmic commented Aug 25, 2020

This looks like a missing, but valid, edge on the wbufSpans lock. I'll send a CL.

IIUC, wbufSpans may be taken in any context that allows write barriers. As such, I'm a bit surprised to see its partial order list is not longer. The mheap list (locks held in contexts which may allocate) is significantly longer, but I'd expect contexts which may allocate and contexts which may have write barriers to be very similar.

This difference may just be because we've observed fewer of these edges since write barriers are only enabled during GC, while allocations can happen consistently.

@mknyszek do you see any extra locks that should obviously be added to wbufSpans? https://cs.opensource.google/go/go/+/master:src/runtime/lockrank.go;l=233-234

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 25, 2020

Change https://golang.org/cl/250464 mentions this issue: runtime: add lock partial order edge (fin -> wbufSpans)

@gopherbot gopherbot closed this in 2013f70 Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.