1
0
mirror of https://github.com/golang/go synced 2024-11-15 04:30:32 -07:00

[release-branch.go1.15] runtime: fix panic if newstack at runtime.acquireLockRank

Process may crash becaues acquireLockRank and releaseLockRank may
be called in nosplit context. With optimizations and inlining
disabled, these functions won't get inlined or have their morestack
calls eliminated.
Nosplit is not strictly required for lockWithRank, unlockWithRank
and lockWithRankMayAcquire, just keep consistency with lockrank_on.go
here.

Updates #40843.
Fixes #40845.

Change-Id: I5824119f98a1da66d767cdb9a60dffe768f13c81
GitHub-Last-Rev: 38fd3ccf6e
GitHub-Pull-Request: golang/go#40844
Reviewed-on: https://go-review.googlesource.com/c/go/+/248878
Reviewed-by: Dan Scales <danscales@google.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit b246c0e12f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/252339
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
chainhelen 2020-08-21 16:44:52 +00:00 committed by Dmitri Shuralyov
parent 0ffc5672df
commit a269e5f939

View File

@ -18,19 +18,29 @@ func getLockRank(l *mutex) lockRank {
return 0 return 0
} }
// The following functions may be called in nosplit context.
// Nosplit is not strictly required for lockWithRank, unlockWithRank
// and lockWithRankMayAcquire, but these nosplit annotations must
// be kept consistent with the equivalent functions in lockrank_on.go.
//go:nosplit
func lockWithRank(l *mutex, rank lockRank) { func lockWithRank(l *mutex, rank lockRank) {
lock2(l) lock2(l)
} }
//go:nosplit
func acquireLockRank(rank lockRank) { func acquireLockRank(rank lockRank) {
} }
//go:nosplit
func unlockWithRank(l *mutex) { func unlockWithRank(l *mutex) {
unlock2(l) unlock2(l)
} }
//go:nosplit
func releaseLockRank(rank lockRank) { func releaseLockRank(rank lockRank) {
} }
//go:nosplit
func lockWithRankMayAcquire(l *mutex, rank lockRank) { func lockWithRankMayAcquire(l *mutex, rank lockRank) {
} }