diff options
| author | Ian Lance Taylor <iant@golang.org> | 2017-03-17 13:48:56 -0700 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2017-03-20 22:59:26 +0000 |
| commit | 5dc14af6824ed31eab5a8a16e8e08082c5ddcb14 (patch) | |
| tree | edb684f1e252aa7b3719299202e2caccf5df26e4 /src | |
| parent | 325904fe6a6b3fc4324c517a62fa570fd6efb163 (diff) | |
| download | go-5dc14af6824ed31eab5a8a16e8e08082c5ddcb14.tar.xz | |
runtime: clear signal stack on main thread
This is a workaround for a FreeBSD kernel bug. It can be removed when
we are confident that all people are using the fixed kernel. See #15658.
Updates #15658.
Change-Id: I0ecdccb77ddd0c270bdeac4d3a5c8abaf0449075
Reviewed-on: https://go-review.googlesource.com/38325
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/os_freebsd.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime/os_freebsd.go b/src/runtime/os_freebsd.go index f736019faa..7c989de109 100644 --- a/src/runtime/os_freebsd.go +++ b/src/runtime/os_freebsd.go @@ -240,6 +240,20 @@ func minit() { _g_.m.procid = uint64(*(*uint32)(unsafe.Pointer(&_g_.m.procid))) } + // On FreeBSD before about April 2017 there was a bug such + // that calling execve from a thread other than the main + // thread did not reset the signal stack. That would confuse + // minitSignals, which calls minitSignalStack, which checks + // whether there is currently a signal stack and uses it if + // present. To avoid this confusion, explicitly disable the + // signal stack on the main thread when not running in a + // library. This can be removed when we are confident that all + // FreeBSD users are running a patched kernel. See issue #15658. + if gp := getg(); !isarchive && !islibrary && gp.m == &m0 && gp == gp.m.g0 { + st := stackt{ss_flags: _SS_DISABLE} + sigaltstack(&st, nil) + } + minitSignals() } |
