Skip to content

Crosscompile with race detector fails with fault and panic #49102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
s00500 opened this issue Oct 21, 2021 · 12 comments
Closed

Crosscompile with race detector fails with fault and panic #49102

s00500 opened this issue Oct 21, 2021 · 12 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@s00500
Copy link

s00500 commented Oct 21, 2021

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

$ go version
go version go1.17.2 linux/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="/home/parallels/.cache/go-build"
GOENV="/home/parallels/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/parallels/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/parallels/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="aarch64-buildroot-linux-gnu-ar"
CC="aarch64-buildroot-linux-gnu-gcc"
CXX="aarch64-buildroot-linux-gnu-g++"
CGO_ENABLED="1"
GOMOD="/home/parallels/myproject/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1610822925=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I am using buildroot with an arm aarch64 setup. Then I use the compiler built there as my crosscompiler in the CGO config. I take a simple golang application that has no CGO dependencys, enable CGO and the -race flag, then it fails in the linking step.

What did you expect to see?

I expected I could make the racedetector crosscompile to arm64 if I setup CGO correctly, strangely it fails, am I doing something wrong or is this usecase not currently supported at all ?

What did you see instead?

Linker errors and sometimes a panic (varies on multiple executions)

 GOOS=linux GOARCH=arm64 go build -race -ldflags="-extld=aarch64-buildroot-linux-gnu-gcc" .
# myproject
runtime.mallocgc: relocation target __tsan_malloc not defined
runtime.runfinq: relocation target __tsan_finalizer_goroutine not defined
runtime.(*sweepLocked).sweep: relocation target __tsan_free not defined
runtime.goexit1: relocation target __tsan_go_end not defined
runtime.gfget: relocation target __tsan_malloc not defined
runtime.(*p).init: relocation target __tsan_proc_create not defined
runtime.(*p).destroy: relocation target __tsan_go_end not defined
runtime.(*p).destroy: relocation target __tsan_proc_destroy not defined
runtime.RaceDisable: relocation target __tsan_go_ignore_sync_begin not defined
runtime.RaceEnable: relocation target __tsan_go_ignore_sync_end not defined
runtime.raceinit: relocation target __tsan_init not defined
runtime.raceinit: relocation target __tsan_map_shadow not defined
runtime.racefini: relocation target __tsan_fini not defined
runtime.racemapshadow: relocation target __tsan_map_shadow not defined
runtime.racegostart: relocation target __tsan_go_start not defined
runtime.raceacquireg: relocation target __tsan_acquire not defined
runtime.raceacquirectx: relocation target __tsan_acquire not defined
runtime.racereleaseg: relocation target __tsan_release not defined
runtime.racereleaseacquireg: relocation target __tsan_release_acquire not defined
runtime.racereleasemergeg: relocation target __tsan_release_merge not defined
runtime.stackalloc: relocation target __tsan_malloc not defined
/usr/local/go/pkg/tool/linux_amd64/link: too many errors
unexpected fault address 0x7f83ae826000
fatal error: fault
unexpected fault address 0x7f83ae70e000
fatal error: fault
unexpected fault address 0x7f83ae3ef000
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f83ae826000 pc=0x464c50]

goroutine 398 [running]:
runtime.throw({0x66cc67, 0x4e0a26})
	/usr/local/go/src/runtime/panic.go:1198 +0x71 fp=0xc002f44d00 sp=0xc002f44cd0 pc=0x434271
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:742 +0x2f6 fp=0xc002f44d50 sp=0xc002f44d00 pc=0x44a696
runtime.memmove()
	/usr/local/go/src/runtime/memmove_amd64.s:216 +0x1b0 fp=0xc002f44d58 sp=0xc002f44d50 pc=0x464c50
cmd/link/internal/ld.(*OutBuf).WriteSym(0xc0001132d0, 0xc000586000, 0x47815)
	/usr/local/go/src/cmd/link/internal/ld/outbuf.go:300 +0x195 fp=0xc002f44dd8 sp=0xc002f44d58 pc=0x5ab7f5
cmd/link/internal/ld.writeBlock(0xc000116000, 0x0, 0xc000586000, {0xc001d4cbf0, 0x4a9c, 0x27645}, 0xc, 0x3292a, {0x867280, 0x200, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:994 +0x38c fp=0xc002f44f08 sp=0xc002f44dd8 pc=0x555f6c
cmd/link/internal/ld.writeBlocks.func1(0x0, 0x0, {0xc001d4cbf0, 0x0, 0x0}, 0x0, 0x0, {0x867280, 0x200, 0x200})
	/usr/local/go/src/cmd/link/internal/ld/data.go:951 +0x76 fp=0xc002f44f80 sp=0xc002f44f08 pc=0x555b56
cmd/link/internal/ld.writeBlocks·dwrap·2()
	/usr/local/go/src/cmd/link/internal/ld/data.go:954 +0x63 fp=0xc002f44fe0 sp=0xc002f44f80 pc=0x555aa3
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc002f44fe8 sp=0xc002f44fe0 pc=0x463c41
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc0005a8740)
	/usr/local/go/src/runtime/sema.go:56 +0x25
sync.(*WaitGroup).Wait(0xc002ae5530)
	/usr/local/go/src/sync/waitgroup.go:130 +0x71
cmd/link/internal/ld.asmb(0xc000116000)
	/usr/local/go/src/cmd/link/internal/ld/asmb.go:62 +0x1c5
cmd/link/internal/ld.Main(_, {0x10, 0x20, 0x1, 0x1f, 0x1e, 0x7c00000, {0x67484e, 0x14}, {0x678036, ...}, ...})
	/usr/local/go/src/cmd/link/internal/ld/main.go:343 +0x137f
main.main()
	/usr/local/go/src/cmd/link/main.go:69 +0x1005

goroutine 53 [runnable]:
cmd/link/internal/ld.writeBlocks·dwrap·2()
	/usr/local/go/src/cmd/link/internal/ld/data.go:950
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 54 [runnable]:
cmd/link/internal/ld.writeBlocks·dwrap·2()
	/usr/local/go/src/cmd/link/internal/ld/data.go:950
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 52 [running]:
	goroutine running on other thread; stack unavailable
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 37 [chan send]:
cmd/link/internal/ld.writeBlocks(0xc000116000, 0xc00247e380, 0xc000114000, 0xc000586000, {0xc001d22000, 0xa01a, 0xa01a}, 0x590000, 0x489ae8, {0x867280, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:948 +0x3d6
cmd/link/internal/ld.writeDatblkToOutBuf(...)
	/usr/local/go/src/cmd/link/internal/ld/data.go:1048
cmd/link/internal/ld.datblk(0x57a405, 0x0, 0x43dcc5, 0x0)
	/usr/local/go/src/cmd/link/internal/ld/data.go:1036 +0x65
cmd/link/internal/ld.writeParallel.func1()
	/usr/local/go/src/cmd/link/internal/ld/data.go:1030 +0x70
created by cmd/link/internal/ld.writeParallel
	/usr/local/go/src/cmd/link/internal/ld/data.go:1028 +0x1a5

goroutine 35 [semacquire]:
sync.runtime_Semacquire(0x0)
	/usr/local/go/src/runtime/sema.go:56 +0x25
sync.(*WaitGroup).Wait(0x634c00)
	/usr/local/go/src/sync/waitgroup.go:130 +0x71
cmd/link/internal/ld.writeBlocks(0xc000116000, 0xc00247e2a0, 0xc000114000, 0xc000586000, {0xc00253c000, 0x27e6, 0x3000}, 0x11000, 0x577860, {0x867280, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:966 +0x5fa
cmd/link/internal/ld.CodeblkPad(...)
	/usr/local/go/src/cmd/link/internal/ld/data.go:876
cmd/link/internal/ld.asmb.func1(0x57a400, 0x0, 0xc0000357d0, 0x57bd5a)
	/usr/local/go/src/cmd/link/internal/ld/asmb.go:37 +0xa5
cmd/link/internal/ld.writeParallel.func1()
	/usr/local/go/src/cmd/link/internal/ld/data.go:1030 +0x70
created by cmd/link/internal/ld.writeParallel
	/usr/local/go/src/cmd/link/internal/ld/data.go:1028 +0x1a5

goroutine 51 [runnable]:
cmd/link/internal/ld.writeBlocks·dwrap·2()
	/usr/local/go/src/cmd/link/internal/ld/data.go:950
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 397 [runnable]:
cmd/link/internal/ld.writeBlocks·dwrap·2()
	/usr/local/go/src/cmd/link/internal/ld/data.go:950
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 50 [runnable]:
syscall.Syscall(0x107, 0xffffffffffffff9c, 0xc0026bc960, 0x0)
	/usr/local/go/src/syscall/asm_linux_amd64.s:20 +0x5
syscall.unlinkat(0x0, {0x7ffc4fe0fef9, 0x0}, 0x0)
	/usr/local/go/src/syscall/zsyscall_linux_amd64.go:127 +0xd4
syscall.Unlink(...)
	/usr/local/go/src/syscall/syscall_linux.go:185
os.Remove.func1(...)
	/usr/local/go/src/os/file_unix.go:302
os.ignoringEINTR(...)
	/usr/local/go/src/os/file_posix.go:246
os.Remove({0x7ffc4fe0fef9, 0x26})
	/usr/local/go/src/os/file_unix.go:301 +0x45
cmd/link/internal/ld.mayberemoveoutfile()
	/usr/local/go/src/cmd/link/internal/ld/lib.go:372 +0x4f
cmd/link/internal/ld.linknew.func1()
	/usr/local/go/src/cmd/link/internal/ld/sym.go:64 +0x33
cmd/link/internal/ld.runAtExitFuncs(...)
	/usr/local/go/src/cmd/link/internal/ld/util.go:23
cmd/link/internal/ld.Exit(0x6d2500)
	/usr/local/go/src/cmd/link/internal/ld/util.go:30 +0x37
cmd/link/internal/ld.Exitf({0x671be2, 0x40}, {0x0, 0x0, 0x0})
	/usr/local/go/src/cmd/link/internal/ld/util.go:38 +0xce
cmd/link/internal/ld.afterErrorAction()
	/usr/local/go/src/cmd/link/internal/ld/util.go:49 +0x50
cmd/link/internal/loader.(*ErrorReporter).Errorf(0xc000116010, 0x1da2, {0x67b388, 0x20}, {0xc002f43aa8, 0x1, 0x1})
	/usr/local/go/src/cmd/link/internal/loader/loader.go:2641 +0x195
cmd/link/internal/ld.(*ErrorReporter).errorUnresolved(0xc000116010, 0xc000586000, 0x1da2, 0x23994)
	/usr/local/go/src/cmd/link/internal/ld/errors.go:63 +0x3a6
cmd/link/internal/ld.(*relocSymState).relocsym(0xc002f43e98, 0x1da2, {0x7f83ae1f5210, 0x3a0, 0xccf4cb})
	/usr/local/go/src/cmd/link/internal/ld/data.go:230 +0x2f10
cmd/link/internal/ld.writeBlock(0xc000116000, 0xc000586000, 0xc000586000, {0xc00253c000, 0x27e6, 0xc00128c000}, 0x1f72, 0x0, {0x867280, 0x200, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:995 +0x3ac
cmd/link/internal/ld.writeBlocks.func1(0xc002acc530, 0xc0017547d0, {0xc00253c000, 0x5, 0xc00128c000}, 0x1f72, 0x2400, {0x867280, 0x200, 0x200})
	/usr/local/go/src/cmd/link/internal/ld/data.go:951 +0x76
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 55 [running]:
	goroutine running on other thread; stack unavailable
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f83ae3ef000 pc=0x464f18]

goroutine 52 [running]:
runtime.throw({0x66cc67, 0x19})
	/usr/local/go/src/runtime/panic.go:1198 +0x71 fp=0xc0017f9d00 sp=0xc0017f9cd0 pc=0x434271
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:742 +0x2f6 fp=0xc0017f9d50 sp=0xc0017f9d00 pc=0x44a696
runtime.memmove()
	/usr/local/go/src/runtime/memmove_amd64.s:401 +0x478 fp=0xc0017f9d58 sp=0xc0017f9d50 pc=0x464f18
cmd/link/internal/ld.(*OutBuf).WriteSym(0xc0015160e0, 0xc000586000, 0x81e2)
	/usr/local/go/src/cmd/link/internal/ld/outbuf.go:300 +0x195 fp=0xc0017f9dd8 sp=0xc0017f9d58 pc=0x5ab7f5
cmd/link/internal/ld.writeBlock(0xc000116000, 0xc000586000, 0xc000586000, {0xc002543a28, 0x18a1, 0xc00167c640}, 0x1, 0x100000000000000, {0x867280, 0x200, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:994 +0x38c fp=0xc0017f9f08 sp=0xc0017f9dd8 pc=0x555f6c
cmd/link/internal/ld.writeBlocks.func1(0xc0017b0000, 0xc000036fd0, {0xc002543a28, 0x0, 0xc00167c640}, 0x1, 0x1, {0x867280, 0x200, 0x200})
	/usr/local/go/src/cmd/link/internal/ld/data.go:951 +0x76 fp=0xc0017f9f80 sp=0xc0017f9f08 pc=0x555b56
cmd/link/internal/ld.writeBlocks·dwrap·2()
	/usr/local/go/src/cmd/link/internal/ld/data.go:954 +0x63 fp=0xc0017f9fe0 sp=0xc0017f9f80 pc=0x555aa3
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc0017f9fe8 sp=0xc0017f9fe0 pc=0x463c41
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f83ae70e000 pc=0x464ece]

goroutine 55 [running]:
runtime.throw({0x66cc67, 0x4e0a26})
	/usr/local/go/src/runtime/panic.go:1198 +0x71 fp=0xc0017fdd00 sp=0xc0017fdcd0 pc=0x434271
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:742 +0x2f6 fp=0xc0017fdd50 sp=0xc0017fdd00 pc=0x44a696
runtime.memmove()
	/usr/local/go/src/runtime/memmove_amd64.s:383 +0x42e fp=0xc0017fdd58 sp=0xc0017fdd50 pc=0x464ece
cmd/link/internal/ld.(*OutBuf).WriteSym(0xc001516230, 0xc000586000, 0x3)
	/usr/local/go/src/cmd/link/internal/ld/outbuf.go:300 +0x195 fp=0xc0017fddd8 sp=0xc0017fdd58 pc=0x5ab7f5
cmd/link/internal/ld.writeBlock(0xc000116000, 0xc0004fe7b0, 0xc000586000, {0xc00254e858, 0x2db, 0x1}, 0x1, 0x0, {0x867280, 0x200, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:994 +0x38c fp=0xc0017fdf08 sp=0xc0017fddd8 pc=0x555f6c
cmd/link/internal/ld.writeBlocks.func1(0xc002accb70, 0x43dcc5, {0xc00254e858, 0x130000c0004fe7d0, 0x39}, 0xc002acdd30, 0xc0007c9b00, {0x867280, 0x200, 0x200})
	/usr/local/go/src/cmd/link/internal/ld/data.go:951 +0x76 fp=0xc0017fdf80 sp=0xc0017fdf08 pc=0x555b56
cmd/link/internal/ld.writeBlocks·dwrap·2()
	/usr/local/go/src/cmd/link/internal/ld/data.go:954 +0x63 fp=0xc0017fdfe0 sp=0xc0017fdf80 pc=0x555aa3
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc0017fdfe8 sp=0xc0017fdfe0 pc=0x463c41
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

@seankhliao
Copy link
Member

how did you install go?

@s00500
Copy link
Author

s00500 commented Oct 21, 2021

Downloaded the official 1.17.2 release, extracted it and moved it into /usr/local/go, then adjusted GOROOT and the PATH in my shell config

@cherrymui
Copy link
Member

Those symbols are defined in runtime/race/race_linux_arm64.syso . Maybe somehow it didn't get included in the build?

Did you set CGO_ENABLED=1 and CC to the path of the C cross compiler when you run the build command? The -extld flag shouldn't be necessary if you set CC correctly.

Maybe paste the output of go build -x? Thanks.

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 21, 2021
@s00500
Copy link
Author

s00500 commented Oct 21, 2021

@cherrymui You can see in my "go env" output that CC CXX and AR variables are set and CGO_ENABLES is set to 1
The output of go buld -x is quite a lot, maybe I will create a simpler test program...

@cherrymui
Copy link
Member

I verified that with Go 1.17.2 GOARCH=arm64 GOOS=linux CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc go build -race works for me.

@cherrymui
Copy link
Member

Yeah, I saw the go env output. But "go env"'s output depends on GOARCH and GOOS also. It seems when you run "go env" you didn't set GOARCH to arm64 at least as it says GOARCH="amd64".

@s00500
Copy link
Author

s00500 commented Oct 21, 2021

CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -race -x .
WORK=/tmp/go-build292769131
mkdir -p $WORK/b001/
cat >$WORK/b001/importcfg.link << 'EOF' # internal
packagefile helloworld=/home/parallels/.cache/go-build/9a/9a5863091eb9fd039d06b877186dcfaca8b75c208ee4a4ab019dfbd0ab862460-d
packagefile fmt=/home/parallels/.cache/go-build/3f/3f68fcb353bd2bc7a7ebedaebc79ae56d3dbc21355bc3b5806ee32e9013e1d29-d
packagefile runtime=/home/parallels/.cache/go-build/e1/e1f81d5dd07dfabb2478609340f5451669a26ade9d5589041562ede82ca3a5a0-d
packagefile runtime/race=/home/parallels/.cache/go-build/db/dbfda7b9e11b6f2f580aa519ca3325a5431c205808fa166f7f30eba50883f925-d
packagefile errors=/home/parallels/.cache/go-build/9a/9a18f125420ca59f20a58b062690b27d730da58c755361ef6dc4f0b353aac934-d
packagefile internal/fmtsort=/home/parallels/.cache/go-build/68/68d03de5813eca80c0db0f1281fd8656d4747b0ace66f7e4ae7e134bbe41dc7b-d
packagefile io=/home/parallels/.cache/go-build/40/40984ba621fecfdd5e6a2129316476a3e122832fb01f2d41f87dd2396988ab38-d
packagefile math=/home/parallels/.cache/go-build/38/38447324e516d2d3030f6358eb626327f996d059906e1c6e67299b4c270e536f-d
packagefile os=/home/parallels/.cache/go-build/34/34e78cfa5edba2532fc2199ebd231bd05383b43f176afc3c17fb8aaf56b0e2a7-d
packagefile reflect=/home/parallels/.cache/go-build/2e/2ea64365f35adfdd805dd8bf610eaadd68a759c37c7f432e0e2216b94e3d2574-d
packagefile strconv=/home/parallels/.cache/go-build/b2/b283575b356b7d6de9355e47bf8b2d262bdc59d1ab96e1de4eaf2630e89a0b1e-d
packagefile sync=/home/parallels/.cache/go-build/07/07a61f30410ab227379073550752b9ab03a802b2441b9d5ea299611d7b028496-d
packagefile unicode/utf8=/home/parallels/.cache/go-build/7b/7b7763a3437085aa8f2cdbd533d9c1f73b0b477c31bba86aa0e3f40b2afb02bf-d
packagefile internal/abi=/home/parallels/.cache/go-build/9a/9ac5cefcb04f144e2bc7188c042f69b59e4bb35358f4256ea0935eeccd8107b5-d
packagefile internal/bytealg=/home/parallels/.cache/go-build/8f/8fd8b05616eb555dba6edde0b215b0a8e3e5ea41a735a8632f6613a8bc58495e-d
packagefile internal/cpu=/home/parallels/.cache/go-build/ad/ad74bef12f68a9b185edd1d105bbd7a5655b45eeabebdaf5ea454a9e61c3d73e-d
packagefile internal/goexperiment=/home/parallels/.cache/go-build/26/26c41efdca83bb82ce7877cd5312c690461037d8f0697ebe6fb3c889d6acf67a-d
packagefile runtime/internal/atomic=/home/parallels/.cache/go-build/d6/d66f6d158537e4ad0702af9ecce5323c979c795505e08f697ad64bd9e7a0e0f3-d
packagefile runtime/internal/math=/home/parallels/.cache/go-build/5d/5d8c4937c94c48cb623266cab1878893df5e9bce53848789717640c6d18d6317-d
packagefile runtime/internal/sys=/home/parallels/.cache/go-build/60/60d586921b927ce00054c02137bca1be61b67a58c2e1421e80e4e44f3b6b6146-d
packagefile runtime/cgo=/home/parallels/.cache/go-build/03/03b532b98d7f5254f186b9dc47441662a1f21e91d8294ef2d3cc25850d976b2a-d
packagefile internal/reflectlite=/home/parallels/.cache/go-build/c5/c5b70ec52809562dd5bd0584429e35012a71b7228e5021d97897396a9aa8d325-d
packagefile sort=/home/parallels/.cache/go-build/56/5623630e06ff5071b7b30ebc60f6bab3dbcd092a08ef881c79a70ffc8b2fe4a9-d
packagefile math/bits=/home/parallels/.cache/go-build/db/dba61a93e6ec4edb71d51958f9de1f7cce6eb670036333458ca5b9352774e468-d
packagefile internal/itoa=/home/parallels/.cache/go-build/29/2976a99d77a4f3b55af475fe62eaf4252cd3a12026b843e86f22879bbcbe4fa6-d
packagefile internal/oserror=/home/parallels/.cache/go-build/63/6320f33e792926cd14aec22feada373166088f23fe3d6103ae4b6eff166075da-d
packagefile internal/poll=/home/parallels/.cache/go-build/7c/7c041fdb2a03f3b417172af820688ac92df110f93c0300648347cd02c066a335-d
packagefile internal/syscall/execenv=/home/parallels/.cache/go-build/17/176c734b412c562318b377272f96dcd3b4c3006a90737135632d0a9ea675b81a-d
packagefile internal/syscall/unix=/home/parallels/.cache/go-build/ab/ab77a169f00d42ad0bc32e82857ba087f3158cf5ce96e4b2d3083696b02f9e99-d
packagefile internal/testlog=/home/parallels/.cache/go-build/10/107db37564ae927925c64616df3f5134ec1e7e7b40ab8db3ebe60e82dda7bdfb-d
packagefile internal/unsafeheader=/home/parallels/.cache/go-build/2d/2d951b6e4ffd4c5deaf48e3dfa713f07b7d8bd7a239b92381daac121d560fb27-d
packagefile io/fs=/home/parallels/.cache/go-build/a1/a1506e75751e036b8d519b0b6a9ecaf7de1f9d2298464206e1d7a8e7b1306625-d
packagefile sync/atomic=/home/parallels/.cache/go-build/f4/f48cb39f18d51b862232b84548ada1f1845c0a544f25364e145fb1607c2834d4-d
packagefile syscall=/home/parallels/.cache/go-build/15/1596c61bf60eae3c13ce15a04295084a6957dd3dbfe9a909cf1b14c16cacf1df-d
packagefile time=/home/parallels/.cache/go-build/56/561b5a0c48f07874894187f4568e261313d4b20b6c7ee76f2991bb7bdd1fb404-d
packagefile unicode=/home/parallels/.cache/go-build/42/42fa8e40fb7b2b063c337accaa22576a27c38261e97222e41c631d0919bc0162-d
packagefile internal/race=/home/parallels/.cache/go-build/59/59c42028233ba627cf06662158dbd6124ce3f1848062626e914731a510efd297-d
packagefile path=/home/parallels/.cache/go-build/b1/b1f9285c92cd26a1109636a5439c6cbac03abd12ee8f98c4a3358e147026669b-d
EOF
mkdir -p $WORK/b001/exe/
cd .
/usr/local/go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -installsuffix race -buildmode=exe -buildid=mbgg1DTIV6RNPDkjV3Qh/XwtxirsIPOlTTVcLSJ_c/oLOGmPgz6V_sN-xxLxn1/mbgg1DTIV6RNPDkjV3Qh -race -extld=aarch64-buildroot-linux-gnu-gcc /home/parallels/.cache/go-build/9a/9a5863091eb9fd039d06b877186dcfaca8b75c208ee4a4ab019dfbd0ab862460-d
# helloworld
runtime.mallocgc: relocation target __tsan_malloc not defined
runtime.runfinq: relocation target __tsan_finalizer_goroutine not defined
runtime.(*sweepLocked).sweep: relocation target __tsan_free not defined
runtime.goexit1: relocation target __tsan_go_end not defined
runtime.gfget: relocation target __tsan_malloc not defined
runtime.(*p).init: relocation target __tsan_proc_create not defined
runtime.(*p).destroy: relocation target __tsan_go_end not defined
runtime.(*p).destroy: relocation target __tsan_proc_destroy not defined
runtime.RaceDisable: relocation target __tsan_go_ignore_sync_begin not defined
runtime.RaceEnable: relocation target __tsan_go_ignore_sync_end not defined
runtime.raceinit: relocation target __tsan_init not defined
runtime.raceinit: relocation target __tsan_map_shadow not defined
runtime.racefini: relocation target __tsan_fini not defined
runtime.racemapshadow: relocation target __tsan_map_shadow not defined
runtime.racegostart: relocation target __tsan_go_start not defined
runtime.raceacquireg: relocation target __tsan_acquire not defined
runtime.raceacquirectx: relocation target __tsan_acquire not defined
runtime.racereleaseg: relocation target __tsan_release not defined
runtime.racereleaseacquireg: relocation target __tsan_release_acquire not defined
runtime.racereleasemergeg: relocation target __tsan_release_merge not defined
runtime.stackalloc: relocation target __tsan_malloc not defined
/usr/local/go/pkg/tool/linux_amd64/link: too many errors
unexpected fault address 0x7f46bdf1b000
fatal error: fault

Ok, thanks for testing, that sounds promising

Yes true, I set GOOS and GOARCH just for the command

@s00500
Copy link
Author

s00500 commented Oct 21, 2021

Hm... I have switched from the buildroot created compiler to the ubuntu gcc-aarch64-linux-gnu package now... still does not work with a minimal hello world example...

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/parallels/.cache/go-build"
GOENV="/home/parallels/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/parallels/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/parallels/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="aarch64-linux-gnu-ar"
CC="aarch64-linux-gnu-gcc"
CXX="aarch64-linux-gnu-g++"
CGO_ENABLED="1"
GOMOD="/home/parallels/helloworld/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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2289820038=/tmp/go-build -gno-record-gcc-switches"

go build -race .
# helloworld
runtime.mallocgc: relocation target __tsan_malloc not defined
runtime.runfinq: relocation target __tsan_finalizer_goroutine not defined
runtime.(*sweepLocked).sweep: relocation target __tsan_free not defined
runtime.goexit1: relocation target __tsan_go_end not defined
runtime.gfget: relocation target __tsan_malloc not defined
runtime.(*p).init: relocation target __tsan_proc_create not defined
runtime.(*p).destroy: relocation target __tsan_go_end not defined
runtime.(*p).destroy: relocation target __tsan_proc_destroy not defined
runtime.RaceDisable: relocation target __tsan_go_ignore_sync_begin not defined
runtime.RaceEnable: relocation target __tsan_go_ignore_sync_end not defined
runtime.raceinit: relocation target __tsan_init not defined
runtime.raceinit: relocation target __tsan_map_shadow not defined
runtime.racefini: relocation target __tsan_fini not defined
runtime.racemapshadow: relocation target __tsan_map_shadow not defined
runtime.racegostart: relocation target __tsan_go_start not defined
runtime.raceacquireg: relocation target __tsan_acquire not defined
runtime.raceacquirectx: relocation target __tsan_acquire not defined
runtime.racereleaseg: relocation target __tsan_release not defined
runtime.racereleaseacquireg: relocation target __tsan_release_acquire not defined
runtime.racereleasemergeg: relocation target __tsan_release_merge not defined
runtime.stackalloc: relocation target __tsan_malloc not defined
/usr/local/go/pkg/tool/linux_amd64/link: too many errors
unexpected fault address 0x7fc58e2c1000
fatal error: fault

@cherrymui
Copy link
Member

cherrymui commented Oct 21, 2021

Thanks.

It looks like the binary release from https://golang.org/dl/go1.17.2.linux-amd64.tar.gz only contains the host platform's race syso file, i.e. it only includes runtime/race/race_linux_amd64.syso but not others (e.g. race_linux_arm64.syso). Maybe you'd need to build from source if you want to cross compile race build, or grab the syso file from the linux-arm64 release package.

@golang/release is it intentional that binary releases only include the race syso for the host?

Maybe the linker (or the Go command) could give a better error message in this case. I'll look into that.

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Oct 21, 2021
@ALTree
Copy link
Member

ALTree commented Oct 21, 2021

Looks intentional: CL 144281 (cmd/release: don't ship race detector *.syso for other platforms).

@cherrymui
Copy link
Member

Thanks @ALTree . It does look intentional. So @s00500 you'd have to grab the syso from somewhere else, either from the source package or other platform's release package, and place it into GOROOT/src/runtime/race.

It seems the main issue is resolved so we can close this. Thanks.

I'll look into printing a better error.

@s00500
Copy link
Author

s00500 commented Oct 21, 2021

@cherrymui Awesome, I just tested, I took the syso file from the arm64 distribution in src/runtime/race/race_linux_arm64.so and placed it into my local installation

Worked like a charm, thanks so much for the superfast help, and yes a better error would definitely help!

Have a nice day, thanks again

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants