aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_dragonfly_amd64.s
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-01-21 12:38:05 -0800
committerIan Lance Taylor <iant@golang.org>2016-01-21 23:21:47 +0000
commit4c4476c297e0a43bf92e8303da369cdc18e5745c (patch)
tree6cc1028788436b117eedcd64e03236a93672daa3 /src/runtime/sys_dragonfly_amd64.s
parent489f65b52ad28c2a6f4f2dc58a3d939e9a77be47 (diff)
downloadgo-4c4476c297e0a43bf92e8303da369cdc18e5745c.tar.gz
go-4c4476c297e0a43bf92e8303da369cdc18e5745c.zip
runtime: on NetBSD and DragonFly drop signal stack in new thread
On NetBSD and DragonFly a newly created thread inherits the signal stack of the creating thread. This breaks horribly if both threads get a signal at the same time. Fix this by dropping the signal stack in the newly created thread. The right signal stack will then get installed later. Note that cgo code that calls pthread_create will have the wrong, duplicated, signal stack in the newly created thread. I don't see any way to fix that in Go. People using cgo to call pthread_create will have to be aware of the problem. Fixes #13945. Fixes #13947. Change-Id: I0c7bd2cdf9ada575d57182ca5e9523060de34931 Reviewed-on: https://go-review.googlesource.com/18814 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/sys_dragonfly_amd64.s')
-rw-r--r--src/runtime/sys_dragonfly_amd64.s12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime/sys_dragonfly_amd64.s b/src/runtime/sys_dragonfly_amd64.s
index d1b94e1bfd..4e4d793c43 100644
--- a/src/runtime/sys_dragonfly_amd64.s
+++ b/src/runtime/sys_dragonfly_amd64.s
@@ -51,6 +51,18 @@ TEXT runtime·lwp_start(SB),NOSPLIT,$0
MOVQ R13, g_m(DI)
MOVQ DI, g(CX)
+ // On DragonFly, a new thread inherits the signal stack of the
+ // creating thread. That confuses minit, so we remove that
+ // signal stack here before calling the regular mstart. It's
+ // a bit baroque to remove a signal stack here only to add one
+ // in minit, but it's a simple change that keeps DragonFly
+ // working like other OS's. At this point all signals are
+ // blocked, so there is no race.
+ SUBQ $8, SP
+ MOVQ $0, 0(SP)
+ CALL runtime·signalstack(SB)
+ ADDQ $8, SP
+
CALL runtime·stackcheck(SB)
CALL runtime·mstart(SB)