Skip to content

Commit a269e5f

Browse files
chainhelendmitshur
authored andcommitted
[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: 38fd3cc GitHub-Pull-Request: #40844 Reviewed-on: https://go-review.googlesource.com/c/go/+/248878 Reviewed-by: Dan Scales <[email protected]> Run-TryBot: Emmanuel Odeke <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> (cherry picked from commit b246c0e) Reviewed-on: https://go-review.googlesource.com/c/go/+/252339 Run-TryBot: Dmitri Shuralyov <[email protected]>
1 parent 0ffc567 commit a269e5f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/runtime/lockrank_off.go

+10
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,29 @@ func getLockRank(l *mutex) lockRank {
1818
return 0
1919
}
2020

21+
// The following functions may be called in nosplit context.
22+
// Nosplit is not strictly required for lockWithRank, unlockWithRank
23+
// and lockWithRankMayAcquire, but these nosplit annotations must
24+
// be kept consistent with the equivalent functions in lockrank_on.go.
25+
26+
//go:nosplit
2127
func lockWithRank(l *mutex, rank lockRank) {
2228
lock2(l)
2329
}
2430

31+
//go:nosplit
2532
func acquireLockRank(rank lockRank) {
2633
}
2734

35+
//go:nosplit
2836
func unlockWithRank(l *mutex) {
2937
unlock2(l)
3038
}
3139

40+
//go:nosplit
3241
func releaseLockRank(rank lockRank) {
3342
}
3443

44+
//go:nosplit
3545
func lockWithRankMayAcquire(l *mutex, rank lockRank) {
3646
}

0 commit comments

Comments
 (0)