From: Joel Sing Date: Mon, 9 Jul 2018 18:54:37 +0000 (+1000) Subject: runtime: correct new thread stack for openbsd MAP_STACK X-Git-Tag: go1.11beta2~147 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8ec35ab66ae4abdb98b3b0d7c3ca4522601c7168;p=gostls13.git runtime: correct new thread stack for openbsd MAP_STACK OpenBSD 6.4 will require the stack pointer to be pointing at an area that is marked as MAP_STACK when entering and exiting syscalls. Adjust the stack pointer used for a new thread such that it points within the stack, not at the top of it (i.e. outside). Fixes #26142 Change-Id: I905bd8e5be3dfc325392e7ac490fb56a7c71b3aa Reviewed-on: https://go-review.googlesource.com/122735 Reviewed-by: Austin Clements Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot --- diff --git a/src/runtime/os_openbsd.go b/src/runtime/os_openbsd.go index 1660511616..96112cb25b 100644 --- a/src/runtime/os_openbsd.go +++ b/src/runtime/os_openbsd.go @@ -6,6 +6,7 @@ package runtime import ( "runtime/internal/atomic" + "runtime/internal/sys" "unsafe" ) @@ -182,10 +183,12 @@ func newosproc(mp *m) { print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " id=", mp.id, " ostk=", &mp, "\n") } + // Stack pointer must point inside stack area (as marked with MAP_STACK), + // rather than at the top of it. param := tforkt{ tf_tcb: unsafe.Pointer(&mp.tls[0]), tf_tid: (*int32)(unsafe.Pointer(&mp.procid)), - tf_stack: uintptr(stk), + tf_stack: uintptr(stk) - sys.PtrSize, } var oset sigset