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

runtime/race: externally link, PIE, race-enabled executable crashes on startup #15443

mwhudson opened this issue Apr 26, 2016 · 4 comments


Copy link

Please answer these questions before submitting your issue. Thanks!

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

go version devel +91824fb Fri Apr 22 10:21:03 2016 +1200 linux/amd64


go version go1.6.1 linux/amd64

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

linux/amd64, 16.04 or 16.10

  1. What did you do?

go run -ldflags='-linkmode=external -extldflags=-pie' -race /opt/opensource/go-test-cases/trivial.go

  1. What did you expect to see?

No output.

  1. What did you see instead?

==12590==ERROR: ThreadSanitizer failed to allocate 0x2698000 (40468480) bytes at address 1765924f4c680 (errno: 12)
signal: segmentation fault (core dumped)

This came to my attention because the development release of Ubuntu has enabled PIE by default on amd64 and ./all.bash fails in the "Testing race detector" step. This could be patched around by passing -no-pie to the external linker when -race is passed to the linker but that seems like a short term hack only.

Copy link
Contributor Author

cc @dvyukov @ianlancetaylor

@dvyukov dvyukov self-assigned this Apr 26, 2016
Copy link

dvyukov commented Apr 26, 2016

It's a miracle that it works at all with external linking! :)

I can reproduce the issue with -pie. ThreadSanitizer shadow memory mapping is tricky. Let's do -no-pie for now.

Copy link

dvyukov commented Apr 26, 2016

Btw, tsan tries to map shadow at 0x1765924f4c680. Tsan shadow mapping for Go/linux is:

uptr MemToShadow(uptr x) {
  return (x * 4) | 0x200000000000ull;

It means that the binary is mapped at 0x555555555555. That used to be 0x7f0000000000. Whoever did that broke C++ ThreadSanitizer on Ubuntu.

Copy link

CL mentions this issue.

@golang golang locked and limited conversation to collaborators Apr 26, 2017
@rsc rsc unassigned dvyukov Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

3 participants