[TSan] fix Go runtime test on amd64 with PIE
authorMartin Pelikan <martin.pelikan@gmail.com>
Thu, 15 Mar 2018 12:10:43 +0000 (12:10 +0000)
committerMartin Pelikan <martin.pelikan@gmail.com>
Thu, 15 Mar 2018 12:10:43 +0000 (12:10 +0000)
commite0207e4948b31338bb4190eca6ad5d8faa24ca12
tree14c09cb9cd45ff25ca99d4255e9a121fa2b3bf66
parent3cc5710cec68e41bca7a073b4a0ade31a9d12da6
[TSan] fix Go runtime test on amd64 with PIE

Summary:
Without this diff, the test segfaults.  Examining the generated executable
(which gets auto-deleted likely by cmake/ninja) yields this error message:

ThreadSanitizer failed to allocate 0x4000 (16384) bytes at address 1755558480000 (errno: 12)

Note that the address has more than 47 bits, which on amd64 means special
treatment and therefore points out an overflow.  The allocation came from
__tsan_map_shadow on a .data pointer, which (on my work Debian-based box)
means the 0x550000000000 range.  This doesn't correspond to the constants
mentioned in tsan_platform.h for Go binaries on Linux/amd64.

The diff therefore allocates memory in the sort of area Go programs would,
and prevents the test from crashing.  It would be nice if reviewers kindly
considered other setups and architectures :-)

Reviewers: kcc, dvyukov

Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D44071

llvm-svn: 327621
compiler-rt/lib/tsan/go/test.c