Skip to content
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

affected/package: go #51523

Closed
walterjwhite opened this issue Mar 7, 2022 · 6 comments
Closed

affected/package: go #51523

walterjwhite opened this issue Mar 7, 2022 · 6 comments

Comments

@walterjwhite
Copy link

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

1.17.5

Does this issue reproduce with the latest release?

unsure, using precompiled package for FreeBSD

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

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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=/tmp/go-build1030940826=/tmp/go-build -gno-record-gcc-switches"

go env Output
$ go env

What did you do?

I wrote an application using chromedp and enabled ASLR on FreeBSD:
sysctl kern.elf64.aslr.enable=1
sysctl kern.elf32.aslr.enable=1

Upon running the chromedp application, I get this error:
fatal error: too many address space collisions for -race mode

runtime stack:
runtime.throw({0xcdaec8, 0x30})
/usr/local/go/src/runtime/panic.go:1198 +0x74 fp=0x7fffff27ffa8 sp=0x7fffff27ff78 pc=0x47d134
runtime.(*mheap).sysAlloc(0x1172e80, 0x400000)
/usr/local/go/src/runtime/malloc.go:686 +0x6c7 fp=0x7fffff280040 sp=0x7fffff27ffa8 pc=0x452967
runtime.(*mheap).grow(0x1172e80, 0x1)
/usr/local/go/src/runtime/mheap.go:1347 +0x85 fp=0x7fffff2800b0 sp=0x7fffff280040 pc=0x46eec5
runtime.(*mheap).allocSpan(0x1172e80, 0x1, 0x0, 0x2e)
/usr/local/go/src/runtime/mheap.go:1179 +0x1bd fp=0x7fffff280120 sp=0x7fffff2800b0 pc=0x46e99d
runtime.(*mheap).alloc.func1()
/usr/local/go/src/runtime/mheap.go:913 +0x8c fp=0x7fffff280170 sp=0x7fffff280120 pc=0x46e3ec
runtime.(*mheap).alloc(0x1172e80, 0x1, 0x2e, 0x1)
/usr/local/go/src/runtime/mheap.go:907 +0x8e fp=0x7fffff2801c0 sp=0x7fffff280170 pc=0x46e2ce
runtime.(*mcentral).grow(0x1185348)
/usr/local/go/src/runtime/mcentral.go:241 +0x79 fp=0x7fffff280210 sp=0x7fffff2801c0 pc=0x45eaf9
runtime.(*mcentral).cacheSpan(0x1185348)
/usr/local/go/src/runtime/mcentral.go:161 +0x7e5 fp=0x7fffff280290 sp=0x7fffff280210 pc=0x45e905
runtime.(*mcache).refill(0x80afa8108, 0x2e)
/usr/local/go/src/runtime/mcache.go:162 +0xaa fp=0x7fffff2802d8 sp=0x7fffff280290 pc=0x45d92a
runtime.(*mcache).nextFree(0x80afa8108, 0x2e)
/usr/local/go/src/runtime/malloc.go:880 +0x8d fp=0x7fffff280318 sp=0x7fffff2802d8 pc=0x452a0d
runtime.mallocgc(0x188, 0xcbb3e0, 0x1)
/usr/local/go/src/runtime/malloc.go:1071 +0x530 fp=0x7fffff2803a8 sp=0x7fffff280318 pc=0x4530f0
runtime.newobject(0xcbb3e0)
/usr/local/go/src/runtime/malloc.go:1228 +0x38 fp=0x7fffff2803d8 sp=0x7fffff2803a8 pc=0x453718
runtime.malg(0x8000)
/usr/local/go/src/runtime/proc.go:4220 +0x31 fp=0x7fffff280418 sp=0x7fffff2803d8 pc=0x489131
runtime.mpreinit(0x115a0e0)
/usr/local/go/src/runtime/os_freebsd.go:295 +0x29 fp=0x7fffff280438 sp=0x7fffff280418 pc=0x4795c9
runtime.mcommoninit(0x115a0e0, 0xffffffffffffffff)
/usr/local/go/src/runtime/proc.go:803 +0x13a fp=0x7fffff280480 sp=0x7fffff280438 pc=0x4814ba
runtime.schedinit()
/usr/local/go/src/runtime/proc.go:691 +0xcf fp=0x7fffff2804e0 sp=0x7fffff280480 pc=0x480fef
runtime.rt0_go()
/usr/local/go/src/runtime/asm_amd64.s:212 +0x125 fp=0x7fffff2804e8 sp=0x7fffff2804e0 pc=0x4b0a65

What did you expect to see?

no error, applications works the same as if ASLR were disabled.

What did you see instead?

see above error

@emaste
Copy link

emaste commented Mar 7, 2022

When I try -race on a hello world:

$ go run -race hello.go
This sanitizer is not compatible with enabled ASLR and binaries compiled with PIE

This issue looks like it is related to llvm/llvm-project#53256

@walterjwhite
Copy link
Author

Ok, so in summary, it is a FreeBSD problem then?

My present options are:

  1. disable -race
  2. disable ASLR

@walterjwhite
Copy link
Author

Yes, I think you're right, this is most likely a duplicate of that. Should this be closed as a duplicate of the other?

@emaste
Copy link

emaste commented Mar 7, 2022

If it's the same issue it is a limitation of the LLVM sanitizers which are apparently used by -race (until just now I wasn't aware of -race or go using the LLVM sanitizers). For now I believe your only options are those two (disable -race or disable ASLR).

In the FreeBSD base system's built-in copy of the sanitizers we automatically re-exec with ASLR disabled when this happens, and this change should make it into LLVM upstream as well, which should at least provide a better user experience (at the expense of having ASLR disabled). freebsd/freebsd-src@930a7c2

In any case I think there is nothing to do in golang itself.

@walterjwhite
Copy link
Author

walterjwhite commented Mar 7, 2022

llvm/llvm-project#53256

@ianlancetaylor
Copy link
Contributor

Also see #27583.

@golang golang locked and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants