]> Cypherpunks repositories - gostls13.git/commit
runtime: fix darwin 386/amd64 stack switches
authorKeith Randall <khr@golang.org>
Thu, 3 May 2018 17:30:31 +0000 (10:30 -0700)
committerKeith Randall <khr@golang.org>
Sat, 19 May 2018 17:38:01 +0000 (17:38 +0000)
commite86c26789dbc11c50c4c49bee55ea015847a97b7
treea6c1cdd109f457edab95df6f29229595cb97a505
parente9137299bf74e1bcac358b569f86aef73c7c2ea6
runtime: fix darwin 386/amd64 stack switches

A few libc_ calls were missing stack switches.

Unfortunately, adding the stack switches revealed a deeper problem.
systemstack() is fundamentally flawed because when you do

    systemstack(func() { ... })

There's no way to mark the anonymous function as nosplit.  At first I
thought it didn't matter, as that function runs on the g0 stack.  But
nosplit is still required, because some syscalls are done when stack
bounds are not set up correctly (e.g. in a signal handler, which runs
on the g0 stack, but g is still pointing at the g stack).  Instead use
asmcgocall and funcPC, so we can be nosplit all the way down.

Mid-stack inlining now pushes darwin over the nosplit limit also.
Leaving that as a TODO.
Update #23168

This might fix the cause of occasional darwin hangs.
Update #25181

Update #17490

Change-Id: If9c3ef052822c7679f5a1dd192443f714483327e
Reviewed-on: https://go-review.googlesource.com/111258
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/link/internal/ld/dwarf_test.go
src/runtime/asm_386.s
src/runtime/mmap.go
src/runtime/os_darwin.go
src/runtime/stubs2.go
src/runtime/sys_darwin.go
src/runtime/sys_darwin_386.s
src/runtime/sys_darwin_amd64.s