diff options
author | Russ Cox <rsc@golang.org> | 2021-01-27 11:27:25 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2021-02-19 00:04:07 +0000 |
commit | 5421c37a1db5098659f86b21d011fc263d93524e (patch) | |
tree | fc27b4aabac7a4b2e66d91f4dc35aee185476ec1 /src/runtime/sys_windows_arm.s | |
parent | 91cc484ea914fc75e7321d23017d59c9751f5066 (diff) | |
download | go-5421c37a1db5098659f86b21d011fc263d93524e.tar.gz go-5421c37a1db5098659f86b21d011fc263d93524e.zip |
runtime: fix windows/arm externalthreadhandler
Externalthreadhandler was not handling its own stack correctly.
It incorrectly referred to the saved LR slot (uninitialized, it turned out)
as holding the return value from the called function.
Externalthreadhandler is used to call two different functions:
profileloop1 and ctrlhandler1.
Profileloop1 does not return, so no harm done.
Ctrlhandler1 returns a boolean indicating whether the handler
took care of the control event (if true, no other handlers run).
It's hard to say exactly what uninitialized values are likely to
have been returned instead of ctrlhandler1's result, but it
probably wasn't helping matters.
Change-Id: Ia02f1c033df618cb82c2193b3a8241ed048a8b18
Reviewed-on: https://go-review.googlesource.com/c/go/+/288812
Trust: Russ Cox <rsc@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/runtime/sys_windows_arm.s')
-rw-r--r-- | src/runtime/sys_windows_arm.s | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/runtime/sys_windows_arm.s b/src/runtime/sys_windows_arm.s index 42278dcbe7..3f01714c66 100644 --- a/src/runtime/sys_windows_arm.s +++ b/src/runtime/sys_windows_arm.s @@ -250,16 +250,17 @@ TEXT runtime·profileloop(SB),NOSPLIT|NOFRAME,$0 // +----------------+ // 12| argument (r0) | //---+----------------+ -// 8 | param1 | +// 8 | param1 | (also return value for called Go function) // +----------------+ // 4 | param0 | // +----------------+ -// 0 | retval | +// 0 | slot for LR | // +----------------+ // TEXT runtime·externalthreadhandler(SB),NOSPLIT|NOFRAME|TOPFRAME,$0 MOVM.DB.W [R4-R11, R14], (R13) // push {r4-r11, lr} SUB $(m__size + g__size + 20), R13 // space for locals + MOVW R14, 0(R13) // push LR again for anything unwinding the stack MOVW R0, 12(R13) MOVW R1, 16(R13) @@ -298,7 +299,7 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT|NOFRAME|TOPFRAME,$0 MOVW $0, g BL runtime·save_g(SB) - MOVW 0(R13), R0 // load return value + MOVW 8(R13), R0 // load return value ADD $(m__size + g__size + 20), R13 // free locals MOVM.IA.W (R13), [R4-R11, R15] // pop {r4-r11, pc} |