From: chainhelen Date: Fri, 21 Aug 2020 16:44:52 +0000 (+0000) Subject: runtime: fix panic if newstack at runtime.acquireLockRank X-Git-Tag: go1.16beta1~1142 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b246c0e12fd41caf45a0f81eaa4f8fe249fbbc01;p=gostls13.git 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. Fixes #40843 Change-Id: I5824119f98a1da66d767cdb9a60dffe768f13c81 GitHub-Last-Rev: 38fd3ccf6ea03b670c7561c060ccdbccc42fff40 GitHub-Pull-Request: golang/go#40844 Reviewed-on: https://go-review.googlesource.com/c/go/+/248878 Reviewed-by: Dan Scales Run-TryBot: Emmanuel Odeke TryBot-Result: Gobot Gobot --- diff --git a/src/runtime/lockrank_off.go b/src/runtime/lockrank_off.go index 425ca8dd93..32378a9627 100644 --- a/src/runtime/lockrank_off.go +++ b/src/runtime/lockrank_off.go @@ -18,19 +18,29 @@ func getLockRank(l *mutex) lockRank { 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) { lock2(l) } +//go:nosplit func acquireLockRank(rank lockRank) { } +//go:nosplit func unlockWithRank(l *mutex) { unlock2(l) } +//go:nosplit func releaseLockRank(rank lockRank) { } +//go:nosplit func lockWithRankMayAcquire(l *mutex, rank lockRank) { }