diff options
author | Austin Clements <austin@google.com> | 2017-06-16 09:23:45 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2017-10-05 20:34:45 +0000 |
commit | 91121ff704b937da9268ef0a7fc71c34233bbd1d (patch) | |
tree | bc7944f41eeac85c957e6c5a65780c9b05af1310 /src/runtime/sys_darwin_amd64.s | |
parent | aac0d52d97351e0b2acaf5bb9b106eafc9e087cb (diff) | |
download | go-91121ff704b937da9268ef0a7fc71c34233bbd1d.tar.gz go-91121ff704b937da9268ef0a7fc71c34233bbd1d.zip |
runtime: fix exit1 arguments on Darwin
exit1 calls the bsdthread_terminate system call on Darwin. Currently
it passes no arguments on 386, arm, and arm64, and an exit status on
amd64. None of these are right. The signature of bsdthread_terminate
is:
int bsdthread_terminate(user_addr_t stackaddr, size_t freesize, uint32_t port, uint32_t sem);
Fix all of the Darwin exit1 implementations to call
bsdthread_terminate with 0 for all of these arguments so it doesn't
try to unmap some random memory, free some random port, or signal a
random semaphore.
This isn't a problem in practice because exit1 is never called.
However, we're about to start using exit1.
Change-Id: Idc534d196e3104e5253fc399553f21eb608693d7
Reviewed-on: https://go-review.googlesource.com/46036
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/sys_darwin_amd64.s')
-rw-r--r-- | src/runtime/sys_darwin_amd64.s | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s index e8ae6fac4f..16125b0d4f 100644 --- a/src/runtime/sys_darwin_amd64.s +++ b/src/runtime/sys_darwin_amd64.s @@ -26,12 +26,19 @@ TEXT runtime·exit(SB),NOSPLIT,$0 // Exit this OS thread (like pthread_exit, which eventually // calls __bsdthread_terminate). TEXT runtime·exit1(SB),NOSPLIT,$0 - MOVL code+0(FP), DI // arg 1 exit status + // __bsdthread_terminate takes 4 word-size arguments. + // Set them all to 0. (None are an exit status.) + MOVL $0, DI + MOVL $0, SI + MOVL $0, DX + MOVL $0, R10 MOVL $(0x2000000+361), AX // syscall entry SYSCALL MOVL $0xf1, 0xf1 // crash RET + + TEXT runtime·open(SB),NOSPLIT,$0 MOVQ name+0(FP), DI // arg 1 pathname MOVL mode+8(FP), SI // arg 2 flags |