go: runtime/race: ThreadSanitizer failed to allocate 0x0000005c9000 (6066176) bytes at 0x200dc940a0000 (error code: 87)
What version of Go are you using (go version
)?
$ go version go version go1.16.4 windows/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 set GO111MODULE=on set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\---\AppData\Local\go-build set GOENV=C:\Users\---\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=c:\---\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=c:\--- set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=c:\---\Go\go1.16.4 set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=c:\---\Go\go1.16.4\pkg\tool\windows_amd64 set GOVERSION=go1.16.4 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=C:\---\go.mod set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\---\AppData\Local\Temp\go-build71564379=/tmp/go-build -gno-record-gcc-switches
What did you do?
Use the source in “Usage” section of https://github.com/go-gl/glfw, then run:
$ go build -race; ./test
What did you expect to see?
The program correctly running, as if -race
was not provided.
What did you see instead?
ERROR: ThreadSanitizer failed to allocate 0x0000005c9000 (6066176) bytes at 0x200dc940a0000 (error code: 87)
The error appears on each run. The count, address and error code are always the same. Using different program, the count and address are different.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 14
- Comments: 51 (14 by maintainers)
Commits related to this issue
- fix: TSAN error on Windows CI Temporary remove `-race` flag Link: https://github.com/golang/go/issues/46099 — committed to ii64/sonic by ii64 2 years ago
- feat: support for Windows (#228) * feat: support for Windows * fix (loader): default loader now has build tag: for linux and darwin * feat (loader): add memory allocator support for Windows * ... — committed to bytedance/sonic by ii64 2 years ago
- Downgrade MinGW in Windows setup scripts. After the switch to MinGW 11.2.0 in #6888, the containerd client integration tests were crashing with an apparent memory allocation error as described in go... — committed to aznashwan/containerd by aznashwan 2 years ago
- Window CI: Downgrade mingw to 10.2.0 - https://github.com/golang/go/issues/46099#issuecomment-1158744544 — committed to praveenkumar/crc by praveenkumar 2 years ago
- [release/1.6] Downgrade MinGW to version 10.2.0 There is currently an issue in the race detector in Go on Windows when used with a newer version of GCC. The issue was first reported here: https://gi... — committed to kzys/containerd by gabriel-samfira 2 years ago
- [release/1.5] Downgrade MinGW to version 10.2.0 There is currently an issue in the race detector in Go on Windows when used with a newer version of GCC. The issue was first reported here: https://gi... — committed to kzys/containerd by gabriel-samfira 2 years ago
- github: Downgrade MinGW on Windows See https://github.com/golang/go/issues/46099 — committed to bep/hugo by bep 2 years ago
- actions: Downgrade mingw to workaround Windows failure Because of https://github.com/golang/go/issues/46099 'make check' on Windows in GitHub Actions is failing with '==34372==ERROR: ThreadSanitizer ... — committed to cfergeau/crc by cfergeau 2 years ago
- workflows: Downgrade mingw to workaround Windows failure Because of https://github.com/golang/go/issues/46099 'make check' on Windows in GitHub Actions is failing with '==34372==ERROR: ThreadSanitize... — committed to cfergeau/crc by cfergeau 2 years ago
- workflows: Downgrade mingw to workaround Windows failure Because of https://github.com/golang/go/issues/46099 'make check' on Windows in GitHub Actions is failing with '==34372==ERROR: ThreadSanitize... — committed to crc-org/crc by cfergeau 2 years ago
- [release/1.5] Downgrade MinGW to version 10.2.0 There is currently an issue in the race detector in Go on Windows when used with a newer version of GCC. The issue was first reported here: https://gi... — committed to yashsingh74/containerd-main by gabriel-samfira 2 years ago
- Remove mingw downgrade Previously we were downgrading mingw to work around an issue in the race detector in Go on Windows when used with a newer version of GCC. The issue was first reported here: go... — committed to dcantah/containerd by dcantah 2 years ago
- Revert "Downgrade MinGW to version 10.2.0" This reverts commit 1ef4bda43301ef1de059346a9c37a0876eb635f3. Previously we were downgrading mingw to work around an issue in the race detector in Go on Wi... — committed to dcantah/containerd by dcantah 2 years ago
- Revert "Downgrade MinGW to version 10.2.0" This reverts commit 1ef4bda43301ef1de059346a9c37a0876eb635f3. Previously we were downgrading mingw to work around an issue in the race detector in Go on Wi... — committed to vvejell1/containerd by dcantah 2 years ago
- ci: remove race detector on Windows 1.18 (https://github.com/golang/go/issues/46099) — committed to SiaFoundation/renterd by n8maninger 2 years ago
- ci: remove race detector on Windows 1.18 (https://github.com/golang/go/issues/46099) — committed to SiaFoundation/renterd by n8maninger 2 years ago
- ci: remove race detector on Windows 1.18 (https://github.com/golang/go/issues/46099) — committed to SiaFoundation/renterd by n8maninger 2 years ago
- Revert "Downgrade MinGW to version 10.2.0" This reverts commit fa2016d58ada2438d0af51a522b528dc228cb4ba Previously we were downgrading mingw to work around an issue in the race detector in Go on Win... — committed to akhilerm/containerd by dcantah 2 years ago
- Revert "workflows: Downgrade mingw to workaround Windows failure" This reverts commit 1b6bf222090f04261ac15d32e223459449638499. Previously we were downgrading mingw to work around an issue in the ra... — committed to anjannath/crc by anjannath a year ago
Run into this suddenly this week, 10.3.0 isn’t working either. Is there a canonical advised development stack?
Happens with dlv too:
Very unhelpful error, where is it from? The Go compiler itself?
I was using TDM but it seems dead/unmaintained so I switched to MinGW and that fails too.
Edit:
So this worked for me:
My gcc is 10.3.0 (tdm64-1). I also met the same problem. According to the comment, I used binutils 2.33.1 and fixed the issue.
go version go1.17.2 windows/amd64 gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) also OK
The
raceinit
function @AlexRouSg pointed to calls__tsan_map_shadow
after rounding its size parameter to a page. __tsan_map_shadow calls MapShadow. That function gets the actual page size (dwPageSize via GetSystemInfo) and further rounds the start and end points of the region. It then calls MmapFixedSuperNoReserve which calls directly to MmapFixedNoReserve. MmapFixedSuperNoReserve has a “FIXME” comment about using large-page support, but it seems like an invitation to an optimization, not a potential bug. On the first call, MapShadow also calls MmapFixedSuperNoReserve for the “data” segment, with explicit 64k alignment. Since the values in the error messages aren’t 64k aligned, I think that’s not the problematic call.both of those values are 4k-aligned (and it looks like 4k is the page size on windows).
According to the docs for VirtualAlloc alignment shouldn’t even be necessary - it rounds as necessary, except in the case of
MEM_LARGE_PAGES
which isn’t in use here.This is all related to point 1 above. I don’t have a good way to start looking at point 2.
So, a few possibilities here:
That first possibility sounds relevant… maybe gcc used to produce 64k-aligned regions in its output, and no longer does?
@benitogf you are out of memory:
I think this is getting a bit farther afield from the original issue (“ThreadSanitizer failed to allocate”). Seems like maybe something is out of whack with your gcc installation.
That looks as though the “-l” is being interpreted by the Go command and not passed to the compiler. I would try fixing up your quoting, e.g. “-gcflags all=-N -l” etc.
@ncantelmo that was it, thanks a lot for all the help!
For future reference for anyone else running into this issue with a Chocolatey-installed MinGW:
mingw = "10.2.0"
worksmingw = "10.3.0"
failsmingw = "11.X.0"
all fail (including11.3.0
)I think you’ve updated minGW too, that’s what’s causing the issue.
I have had the same problem.
This problem carried on with 1.17.x version, however, as @huifly said, downgrading binutils helps so far.
I have been using this custom package from MinGW Distro - nuwen.net, version 17.1 that has gcc 9.2.0 and binutils 2.33.1 bundled and it works with go1.17.6 just fine, however, it appears there are some nice scripts that could enable building custom combination of desired tools so one could have all the packages upgraded while maintaining lower version of binutils.
In addition to that, it is a selfextracting package that only requires setting the path properly, so testing and deploying is rather trivial.