Commit dcdee153 authored by Cherry Zhang's avatar Cherry Zhang

runtime: use innermost frame's func name for async preemption check

We don't asynchronously preempt if we are in the runtime. We do
this by checking the function name. However, it failed to take
inlining into account. If a runtime function gets inlined into
a non-runtime function, it can be preempted, and bad things can
happen. One instance of this is dounlockOSThread inlined into
UnlockOSThread which is in turn inlined into a non-runtime
function.

Fix this by using the innermost frame's function name.

Change-Id: Ifa036ce1320700aaaefd829b4bee0d04d05c395d
Reviewed-on: https://go-review.googlesource.com/c/go/+/211978
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 87a54677
...@@ -411,9 +411,17 @@ func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) bool { ...@@ -411,9 +411,17 @@ func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) bool {
// locals pointer map, like empty frame functions? // locals pointer map, like empty frame functions?
return false return false
} }
if hasPrefix(funcname(f), "runtime.") || name := funcname(f)
hasPrefix(funcname(f), "runtime/internal/") || if inldata := funcdata(f, _FUNCDATA_InlTree); inldata != nil {
hasPrefix(funcname(f), "reflect.") { inltree := (*[1 << 20]inlinedCall)(inldata)
ix := pcdatavalue(f, _PCDATA_InlTreeIndex, pc, nil)
if ix >= 0 {
name = funcnameFromNameoff(f, inltree[ix].func_)
}
}
if hasPrefix(name, "runtime.") ||
hasPrefix(name, "runtime/internal/") ||
hasPrefix(name, "reflect.") {
// For now we never async preempt the runtime or // For now we never async preempt the runtime or
// anything closely tied to the runtime. Known issues // anything closely tied to the runtime. Known issues
// include: various points in the scheduler ("don't // include: various points in the scheduler ("don't
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment