aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2021-08-12 17:17:51 -0400
committerDmitri Shuralyov <dmitshur@golang.org>2021-08-13 16:34:57 +0000
commit0d530843be0021aa56771c2f922e952beb190d97 (patch)
tree86ff7814172334edbcce4742b507e17c364bd1ee
parentd66b2112bd076e29349e1060e812a211a8fa9c32 (diff)
downloadgo-0d530843be0021aa56771c2f922e952beb190d97.tar.gz
go-0d530843be0021aa56771c2f922e952beb190d97.zip
[release-branch.go1.16] runtime: drop SIGPROF while in ARM < 7 kernel helpers
On Linux ARMv6 and below runtime/internal/atomic.Cas calls into a kernel cas helper at a fixed address. If a SIGPROF arrives while executing the kernel helper, the sigprof lostAtomic logic will miss that we are potentially in the spinlock critical section, which could cause a deadlock when using atomics later in sigprof. For #47505 Fixes #47675 Change-Id: If8ba0d0fc47e45d4e6c68eca98fac4c6ed4e43c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/341889 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 20a620fd9f7bc35739c1af3602d53808d0430814) Reviewed-on: https://go-review.googlesource.com/c/go/+/341853
-rw-r--r--src/runtime/proc.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 3ace2b329b..32fe877041 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -4425,7 +4425,7 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
return
}
- // On mips{,le}, 64bit atomics are emulated with spinlocks, in
+ // On mips{,le}/arm, 64bit atomics are emulated with spinlocks, in
// runtime/internal/atomic. If SIGPROF arrives while the program is inside
// the critical section, it creates a deadlock (when writing the sample).
// As a workaround, create a counter of SIGPROFs while in critical section
@@ -4438,6 +4438,13 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
return
}
}
+ if GOARCH == "arm" && goarm < 7 && GOOS == "linux" && pc&0xffff0000 == 0xffff0000 {
+ // runtime/internal/atomic functions call into kernel
+ // helpers on arm < 7. See
+ // runtime/internal/atomic/sys_linux_arm.s.
+ cpuprof.lostAtomic++
+ return
+ }
}
// Profiling runs concurrently with GC, so it must not allocate.