diff --git a/src/runtime/cgo/gcc_sigaction.c b/src/runtime/cgo/gcc_sigaction.c index 566097fa6d7..72fb08d720e 100644 --- a/src/runtime/cgo/gcc_sigaction.c +++ b/src/runtime/cgo/gcc_sigaction.c @@ -10,6 +10,8 @@ #include #include +#include "libcgo.h" + // go_sigaction_t is a C version of the sigactiont struct from // defs_linux_amd64.go. This definition — and its conversion to and from struct // sigaction — are specific to linux/amd64. @@ -33,6 +35,8 @@ x_cgo_sigaction(intptr_t signum, const go_sigaction_t *goact, go_sigaction_t *ol struct sigaction oldact; int i; + _cgo_tsan_acquire(); + memset(&act, 0, sizeof act); memset(&oldact, 0, sizeof oldact); @@ -53,7 +57,8 @@ x_cgo_sigaction(intptr_t signum, const go_sigaction_t *goact, go_sigaction_t *ol ret = sigaction(signum, goact ? &act : NULL, oldgoact ? &oldact : NULL); if (ret == -1) { - /* This is what the Go code expects on failure. */ + // runtime.rt_sigaction expects _cgo_sigaction to return errno on error. + _cgo_tsan_release(); return errno; } @@ -72,5 +77,6 @@ x_cgo_sigaction(intptr_t signum, const go_sigaction_t *goact, go_sigaction_t *ol oldgoact->flags = oldact.sa_flags; } + _cgo_tsan_release(); return ret; }