Skip to content

Commit 15ea61c

Browse files
committed
runtime: clear m.gsignal when the M exits
On some platforms (currently ARM and ARM64), when calling into VDSO we store the G to the gsignal stack, if there is one, so if we receive a signal during VDSO we can find the G. When an M exits, it frees the gsignal stack. But m.gsignal.stack still points to that stack. When we call nanotime on this M, we will write to the already freed gsignal stack, which is bad. Prevent this by unlinking the freed stack from the M. Should fix #35235. Change-Id: I338b1fc8ec62aae036f38afaca3484687e11a40d Reviewed-on: https://go-review.googlesource.com/c/go/+/204158 Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 20d621d commit 15ea61c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/runtime/proc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,11 @@ func mexit(osStack bool) {
11901190
// Free the gsignal stack.
11911191
if m.gsignal != nil {
11921192
stackfree(m.gsignal.stack)
1193+
// On some platforms, when calling into VDSO (e.g. nanotime)
1194+
// we store our g on the gsignal stack, if there is one.
1195+
// Now the stack is freed, unlink it from the m, so we
1196+
// won't write to it when calling VDSO code.
1197+
m.gsignal = nil
11931198
}
11941199

11951200
// Remove m from allm.

0 commit comments

Comments
 (0)