]> Cypherpunks repositories - gostls13.git/commit
syscall: define Syscall in terms of RawSyscall on linux
authorMichael Pratt <mpratt@google.com>
Thu, 24 Feb 2022 21:54:13 +0000 (16:54 -0500)
committerGopher Robot <gobot@golang.org>
Thu, 21 Apr 2022 22:10:49 +0000 (22:10 +0000)
commitbb004a179a034c799809f42d525801ec4a791987
tree3d52dbf47edbaa3e456a5c10e4a26018816de921
parent889a902d215c57fe2032181370a9a2c30c531c99
syscall: define Syscall in terms of RawSyscall on linux

This is a re-do of CL 388477, fixing #52472.

It is unsafe to call syscall.RawSyscall from syscall.Syscall with
-coverpkg=all and -race. This is because:

1. Coverage adds a sync/atomic call in RawSyscall to increment the
   coverage counter.
2. Race mode instruments sync/atomic calls with TSAN runtime calls. TSAN
   eventually calls runtime.racecallbackfunc, which expects
   getg().m.p != 0, which is no longer true after entersyscall().

cmd/go actually avoids adding coverage instrumention to package runtime
in race mode entirely to avoid these kinds of problems. Rather than also
excluding all of syscall for this one function, work around by calling
RawSyscall6 instead, which avoids coverage instrumention both by being
written in assembly and in package runtime/*.

For #51087
Fixes #52472

Change-Id: Iaffd27df03753020c4716059a455d6ca7b62f347
Reviewed-on: https://go-review.googlesource.com/c/go/+/401654
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/proc.go
src/syscall/asm_linux_386.s
src/syscall/asm_linux_amd64.s
src/syscall/asm_linux_arm.s
src/syscall/asm_linux_arm64.s
src/syscall/asm_linux_mips64x.s
src/syscall/asm_linux_mipsx.s
src/syscall/asm_linux_ppc64x.s
src/syscall/asm_linux_riscv64.s
src/syscall/asm_linux_s390x.s
src/syscall/syscall_linux.go