Skip to content

runtime: add race detector for ios/arm64 #39521

Open
@steeve

Description

@steeve

What version of Go are you using (go version)?

master as of the opening of this issue

$ go version
go version devel +5adaa1290e Thu Jun 11 06:04:57 2020 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/steeve/Library/Caches/go-build"
GOENV="/Users/steeve/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/steeve/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/steeve/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/steeve/code/github.com/znly/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/steeve/code/github.com/znly/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/steeve/code/github.com/znly/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gr/T/go-build749515592=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Since darwin/amd64 and linux/arm64 are supported, I figure I'd give it a shot. Applied this patch to try and "enable" the race detector on ios/arm64:

diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go
index c27b3b986d..00faf49f8a 100644
--- a/src/cmd/internal/sys/supported.go
+++ b/src/cmd/internal/sys/supported.go
@@ -13,8 +13,10 @@ func RaceDetectorSupported(goos, goarch string) bool {
 	switch goos {
 	case "linux":
 		return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64"
-	case "darwin", "freebsd", "netbsd", "windows":
+	case "freebsd", "netbsd", "windows":
 		return goarch == "amd64"
+	case "darwin":
+		return goarch == "amd64" || goarch == "arm64"
 	default:
 		return false
 	}

What did you expect to see?

Hopefully a successful build with the race detector enabled.

What did you see instead?

The linker fails/crashes with the following:

Use --sandbox_debug to see verbose messages from the sandbox
runtime.rt0_go: missing section for runtime.tls_g
runtime.load_g: missing section for runtime.tls_g
runtime.save_g: missing section for runtime.tls_g
runtime.rt0_go: reloc 3 (R_ADDRARM64) to non-macho symbol runtime.tls_g type=37 (STLSBSS)
runtime.rt0_go: unsupported obj reloc 3 (R_ADDRARM64)/8 to runtime.tls_g
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x2 pc=0x1213e6e]

goroutine 1 [running]:
cmd/link/internal/arm64.machoreloc1(0x1473b20, 0xc0000b6070, 0xc0049bd000, 0xc005222c40, 0x642e4, 0x1)
	/Users/steeve/code/github.com/znly/go/src/cmd/link/internal/arm64/asm.go:388 +0x4ce
cmd/link/internal/ld.machorelocsect(0xc000071880, 0xc0000b62a0, 0xc001a50000, 0x4279, 0x4279)
	/Users/steeve/code/github.com/znly/go/src/cmd/link/internal/ld/macho.go:1067 +0x18c
cmd/link/internal/ld.Machoemitreloc(0xc000071880)
	/Users/steeve/code/github.com/znly/go/src/cmd/link/internal/ld/macho.go:1081 +0xca
cmd/link/internal/arm64.asmb2(0xc000071880)
	/Users/steeve/code/github.com/znly/go/src/cmd/link/internal/arm64/asm.go:912 +0x5a5
cmd/link/internal/ld.Main(0x1473b20, 0x10, 0x20, 0x1, 0x1f, 0x1e, 0x12d3faa, 0x14, 0x12d767f, 0x1a, ...)
	/Users/steeve/code/github.com/znly/go/src/cmd/link/internal/ld/main.go:349 +0x1509
main.main()
	/Users/steeve/code/github.com/znly/go/src/cmd/link/main.go:68 +0x1dc
link: error running subcommand: exit status 2

Mainly opening this issue so the discussion can be had.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Triage Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions