Closed
Description
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