aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/cpuprof.go
diff options
context:
space:
mode:
authorVladimir Stefanovic <vladimir.stefanovic@imgtec.com>2017-05-04 16:45:29 +0200
committerCherry Zhang <cherryyz@google.com>2017-07-26 13:29:59 +0000
commit835dfef939879b284d4c0f4e1726491f27e4f1ee (patch)
treed163be310654d08362c9f7b620bf8e4c46d0dca2 /src/runtime/cpuprof.go
parentdf91b8044dbe790c69c16058330f545be069cc1f (diff)
downloadgo-835dfef939879b284d4c0f4e1726491f27e4f1ee.tar.gz
go-835dfef939879b284d4c0f4e1726491f27e4f1ee.zip
runtime/pprof: prevent a deadlock that SIGPROF might create on mips{,le}
64bit atomics on mips/mipsle are implemented using spinlocks. If SIGPROF is received while the program is in the critical section, it will try to write the sample using the same spinlock, creating a deadloop. Prevent it by creating a counter of SIGPROFs during atomic64 and postpone writing the sample(s) until called from elsewhere, with pc set to _LostSIGPROFDuringAtomic64. Added a test case, per Cherry's suggestion. Works around #20146. Change-Id: Icff504180bae4ee83d78b19c0d9d6a80097087f9 Reviewed-on: https://go-review.googlesource.com/42652 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/cpuprof.go')
-rw-r--r--src/runtime/cpuprof.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/runtime/cpuprof.go b/src/runtime/cpuprof.go
index c761e440b6..fb841a9f3d 100644
--- a/src/runtime/cpuprof.go
+++ b/src/runtime/cpuprof.go
@@ -163,6 +163,15 @@ func (p *cpuProfile) addExtra() {
}
}
+func (p *cpuProfile) addLostAtomic64(count uint64) {
+ hdr := [1]uint64{count}
+ lostStk := [2]uintptr{
+ funcPC(_LostSIGPROFDuringAtomic64) + sys.PCQuantum,
+ funcPC(_System) + sys.PCQuantum,
+ }
+ cpuprof.log.write(nil, 0, hdr[:], lostStk[:])
+}
+
// CPUProfile panics.
// It formerly provided raw access to chunks of
// a pprof-format profile generated by the runtime.