Skip to content

Commit 827584e

Browse files
zhangfannieianlancetaylor
authored andcommitted
runtime: check for nil g in msancall() on arm64
The current msanwrite() segfaults during libpreinit when built with -msan on arm64. The cause is msancall() in runtime/msan_arm64.s called by msanwrite() assumes that it is always called with a valid g, leading to a segfult. This CL adds a check for nil g in msancall(). Fixes #34338 Change-Id: If4ad7e37556cd1d99346c1a7b4852651d1e4e4aa Reviewed-on: https://go-review.googlesource.com/c/go/+/196157 Reviewed-by: Cherry Zhang <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent bcf6f9f commit 827584e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/runtime/msan_arm64.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ TEXT runtime·msanfree(SB), NOSPLIT, $0-16
4747

4848
// Switches SP to g0 stack and calls (FARG). Arguments already set.
4949
TEXT msancall<>(SB), NOSPLIT, $0-0
50+
MOVD RSP, R19 // callee-saved
51+
CBZ g, g0stack // no g, still on a system stack
5052
MOVD g_m(g), R10
5153
MOVD m_g0(R10), R11
52-
MOVD RSP, R19 // callee-saved
5354
CMP R11, g
5455
BEQ g0stack
5556

0 commit comments

Comments
 (0)