mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime,net/http/pprof: goroutine leak detection by using the garbage collector
Proposal #74609
Change-Id: I97a754b128aac1bc5b7b9ab607fcd5bb390058c8
GitHub-Last-Rev: 60f2a192ba
GitHub-Pull-Request: golang/go#74622
Reviewed-on: https://go-review.googlesource.com/c/go/+/688335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: t hepudds <thepudds1460@gmail.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
parent
84db201ae1
commit
8c68a1c1ab
95 changed files with 10766 additions and 89 deletions
|
|
@ -821,7 +821,8 @@ func adjustsudogs(gp *g, adjinfo *adjustinfo) {
|
|||
// the data elements pointed to by a SudoG structure
|
||||
// might be in the stack.
|
||||
for s := gp.waiting; s != nil; s = s.waitlink {
|
||||
adjustpointer(adjinfo, unsafe.Pointer(&s.elem))
|
||||
adjustpointer(adjinfo, unsafe.Pointer(&s.elem.vu))
|
||||
adjustpointer(adjinfo, unsafe.Pointer(&s.elem.vp))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -834,7 +835,7 @@ func fillstack(stk stack, b byte) {
|
|||
func findsghi(gp *g, stk stack) uintptr {
|
||||
var sghi uintptr
|
||||
for sg := gp.waiting; sg != nil; sg = sg.waitlink {
|
||||
p := uintptr(sg.elem) + uintptr(sg.c.elemsize)
|
||||
p := sg.elem.uintptr() + uintptr(sg.c.get().elemsize)
|
||||
if stk.lo <= p && p < stk.hi && p > sghi {
|
||||
sghi = p
|
||||
}
|
||||
|
|
@ -853,7 +854,7 @@ func syncadjustsudogs(gp *g, used uintptr, adjinfo *adjustinfo) uintptr {
|
|||
// Lock channels to prevent concurrent send/receive.
|
||||
var lastc *hchan
|
||||
for sg := gp.waiting; sg != nil; sg = sg.waitlink {
|
||||
if sg.c != lastc {
|
||||
if sg.c.get() != lastc {
|
||||
// There is a ranking cycle here between gscan bit and
|
||||
// hchan locks. Normally, we only allow acquiring hchan
|
||||
// locks and then getting a gscan bit. In this case, we
|
||||
|
|
@ -863,9 +864,9 @@ func syncadjustsudogs(gp *g, used uintptr, adjinfo *adjustinfo) uintptr {
|
|||
// suspended. So, we get a special hchan lock rank here
|
||||
// that is lower than gscan, but doesn't allow acquiring
|
||||
// any other locks other than hchan.
|
||||
lockWithRank(&sg.c.lock, lockRankHchanLeaf)
|
||||
lockWithRank(&sg.c.get().lock, lockRankHchanLeaf)
|
||||
}
|
||||
lastc = sg.c
|
||||
lastc = sg.c.get()
|
||||
}
|
||||
|
||||
// Adjust sudogs.
|
||||
|
|
@ -885,10 +886,10 @@ func syncadjustsudogs(gp *g, used uintptr, adjinfo *adjustinfo) uintptr {
|
|||
// Unlock channels.
|
||||
lastc = nil
|
||||
for sg := gp.waiting; sg != nil; sg = sg.waitlink {
|
||||
if sg.c != lastc {
|
||||
unlock(&sg.c.lock)
|
||||
if sg.c.get() != lastc {
|
||||
unlock(&sg.c.get().lock)
|
||||
}
|
||||
lastc = sg.c
|
||||
lastc = sg.c.get()
|
||||
}
|
||||
|
||||
return sgsize
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue