mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/trace: add missing events for the locked g in extra M.
Extra Ms may lead to the "no consistent ordering of events possible" error when parsing trace file with cgo enabled, since:
1. The gs in the extra Ms may be in `_Gdead` status while starting trace by invoking `runtime.StartTrace`,
2. and these gs will trigger `traceEvGoSysExit` events in `runtime.exitsyscall` when invoking go functions from c,
3. then, the events of those gs are under non-consistent ordering, due to missing the previous events.
Add two events, `traceEvGoCreate` and `traceEvGoInSyscall`, in `runtime.StartTrace`, will make the trace parser happy.
Fixes #29707
Change-Id: I7cc4b80822d2c46591304a59c9da2c9fc470f1d0
GitHub-Last-Rev: 445de8eaf3
GitHub-Pull-Request: golang/go#53284
Reviewed-on: https://go-review.googlesource.com/c/go/+/411034
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
b6f87b0755
commit
ea9c3fd42d
6 changed files with 96 additions and 3 deletions
|
|
@ -187,7 +187,7 @@ func GoroutineStats(events []*Event) map[uint64]*GDesc {
|
|||
gs[g.ID] = g
|
||||
case EvGoStart, EvGoStartLabel:
|
||||
g := gs[ev.G]
|
||||
if g.PC == 0 {
|
||||
if g.PC == 0 && len(ev.Stk) > 0 {
|
||||
g.PC = ev.Stk[0].PC
|
||||
g.Name = ev.Stk[0].Fn
|
||||
}
|
||||
|
|
@ -353,5 +353,6 @@ func RelatedGoroutines(events []*Event, goid uint64) map[uint64]bool {
|
|||
func IsSystemGoroutine(entryFn string) bool {
|
||||
// This mimics runtime.isSystemGoroutine as closely as
|
||||
// possible.
|
||||
return entryFn != "runtime.main" && strings.HasPrefix(entryFn, "runtime.")
|
||||
// Also, locked g in extra M (with empty entryFn) is system goroutine.
|
||||
return entryFn == "" || entryFn != "runtime.main" && strings.HasPrefix(entryFn, "runtime.")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue