fatal error: too many address space collisions for -race mode

253 views
Skip to first unread message

Narayanan Iyer

unread,
Dec 3, 2021, 6:29:58 PM12/3/21
to golang-nuts
Hi,

I have a go application (which uses cgo in case it helps) that started giving the error in the email subject once I added -ldflags 'fsanitize=address' to the go build -race and go test -race commands.

The go build and go test commands had -race turned on from before and have been working fine until now.

I tried googling this but could not find any relevant answers. I did find https://groups.google.com/g/golang-nuts/c/xz8U5SBrOqg/m/2vOjoW4hAQAJ mentioning that Go race detector will not work with C race detector but that is enabled by -fsanitize=thread in my understanding whereas I am using -fsanitize=address above.

Any help in resolving this issue is appreciated. Please let me know if you need any more information. Thanks.

Below is the full error output.

fatal error: too many address space collisions for -race mode

runtime stack:
runtime.throw({0x71a873, 0x4000000})
      /usr/lib/go-1.17/src/runtime/panic.go:1198 +0x71 fp=0x7ffe79ed37c0 sp=0x7ffe79ed3790 pc=0x448b91
runtime.(*mheap).sysAlloc(0x8fdc00, 0x0)
      /usr/lib/go-1.17/src/runtime/malloc.go:686 +0x5c5 fp=0x7ffe79ed3850 sp=0x7ffe79ed37c0 pc=0x41f6e5
runtime.(*mheap).grow(0x8fdc00, 0x7fc4c55ff640)
      /usr/lib/go-1.17/src/runtime/mheap.go:1347 +0x73 fp=0x7ffe79ed38b8 sp=0x7ffe79ed3850 pc=0x439c33
runtime.(*mheap).allocSpan(0x8fdc00, 0x1, 0x0, 0x2e)
      /usr/lib/go-1.17/src/runtime/mheap.go:1179 +0x165 fp=0x7ffe79ed3928 sp=0x7ffe79ed38b8 pc=0x439745
runtime.(*mheap).alloc.func1()
      /usr/lib/go-1.17/src/runtime/mheap.go:913 +0x69 fp=0x7ffe79ed3970 sp=0x7ffe79ed3928 pc=0x439229
runtime.(*mheap).alloc(0x7ffe79ed39f0, 0x685fc0, 0x10, 0x1)
      /usr/lib/go-1.17/src/runtime/mheap.go:907 +0x73 fp=0x7ffe79ed39c0 sp=0x7ffe79ed3970 pc=0x439113
runtime.(*mcentral).grow(0x40000)
      /usr/lib/go-1.17/src/runtime/mcentral.go:241 +0x65 fp=0x7ffe79ed3a08 sp=0x7ffe79ed39c0 pc=0x42aa25
runtime.(*mcentral).cacheSpan(0x9100c8)
      /usr/lib/go-1.17/src/runtime/mcentral.go:161 +0x69e fp=0x7ffe79ed3a80 sp=0x7ffe79ed3a08 pc=0x42a85e
runtime.(*mcache).refill(0x7fc4c5e17108, 0x2e)
      /usr/lib/go-1.17/src/runtime/mcache.go:162 +0xaf fp=0x7ffe79ed3ad0 sp=0x7ffe79ed3a80 pc=0x429a8f
runtime.(*mcache).nextFree(0x7fc4c5e17108, 0x2e)
      /usr/lib/go-1.17/src/runtime/malloc.go:880 +0x85 fp=0x7ffe79ed3b18 sp=0x7ffe79ed3ad0 pc=0x41f7a5
runtime.mallocgc(0x188, 0x70b600, 0x1)
      /usr/lib/go-1.17/src/runtime/malloc.go:1071 +0x4f5 fp=0x7ffe79ed3bb0 sp=0x7ffe79ed3b18 pc=0x41fe35
runtime.newobject(0x4000)
      /usr/lib/go-1.17/src/runtime/malloc.go:1228 +0x27 fp=0x7ffe79ed3bd8 sp=0x7ffe79ed3bb0 pc=0x4203e7
runtime.malg(0x8000)
      /usr/lib/go-1.17/src/runtime/proc.go:4220 +0x28 fp=0x7ffe79ed3c18 sp=0x7ffe79ed3bd8 pc=0x4538c8
runtime.mpreinit(0x8e56c0)
      /usr/lib/go-1.17/src/runtime/os_linux.go:355 +0x25 fp=0x7ffe79ed3c30 sp=0x7ffe79ed3c18 pc=0x445485
runtime.mcommoninit(0x8e56c0, 0xffffffffffffffff)
      /usr/lib/go-1.17/src/runtime/proc.go:803 +0x108 fp=0x7ffe79ed3c70 sp=0x7ffe79ed3c30 pc=0x44c868
runtime.schedinit()
      /usr/lib/go-1.17/src/runtime/proc.go:691 +0xa5 fp=0x7ffe79ed3cd0 sp=0x7ffe79ed3c70 pc=0x44c425
runtime.rt0_go()
      /usr/lib/go-1.17/src/runtime/asm_amd64.s:212 +0x125 fp=0x7ffe79ed3cd8 sp=0x7ffe79ed3cd0 pc=0x47b2c5

Narayanan.

Ian Lance Taylor

unread,
Dec 3, 2021, 9:39:19 PM12/3/21
to Narayanan Iyer, golang-nuts
On Fri, Dec 3, 2021 at 3:29 PM Narayanan Iyer <raja...@gmail.com> wrote:
>
> I have a go application (which uses cgo in case it helps) that started giving the error in the email subject once I added -ldflags 'fsanitize=address' to the go build -race and go test -race commands.
>
> The go build and go test commands had -race turned on from before and have been working fine until now.
>
> I tried googling this but could not find any relevant answers. I did find https://groups.google.com/g/golang-nuts/c/xz8U5SBrOqg/m/2vOjoW4hAQAJ mentioning that Go race detector will not work with C race detector but that is enabled by -fsanitize=thread in my understanding whereas I am using -fsanitize=address above.
>
> Any help in resolving this issue is appreciated. Please let me know if you need any more information. Thanks.

The Go race detector is implemented using the same technology as the C
sanitizers. You can't use multiple sanitizers in the same program.
Using -race with Go is not compatible with using -fsanitize=<anything>
in C. Similarly, in C you can't use both -fsanitize=thread and
-fsanitize=address together. Sorry.

Ian

Narayanan Iyer

unread,
Dec 6, 2021, 8:19:31 AM12/6/21
to golang-nuts
Thanks Ian for the clarification. I will tailor the tests so only one of those sanitizers are turned on in one test run.

Narayanan.
Reply all
Reply to author
Forward
0 new messages