The current implementation of the Go sanitizer only works on x86_64. Added
some modifications to the buildgo.sh script and the Tsan code to make it
work on powerpc64/linux.
Details
- Reviewers
dvyukov
Diff Detail
- Repository
- rCRT Compiler Runtime
- Build Status
Buildable 17069 Build 17069: arc lint + arc unit
Event Timeline
Is there an upstream Go bug for race on powerpc? Please CC me on it.
lib/tsan/go/buildgo.sh | ||
---|---|---|
141 | Please dedup the common part "-DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer" and then add arch-specific flags separately. | |
lib/tsan/rtl/tsan_platform.h | ||
420 | I see that Go heap always starts at 0x00c0 on powerpc: switch { case GOARCH == "arm64" && GOOS == "darwin": p = uintptr(i)<<40 | uintptrMask&(0x0013<<28) case GOARCH == "arm64": p = uintptr(i)<<40 | uintptrMask&(0x0040<<32) default: p = uintptr(i)<<40 | uintptrMask&(0x00c0<<32) } And you don't cover this region, instead it's occupied by shadow. |
Version 2: update memory mappings, changed buildgo.sh FLAGS.
- Note: decided to drop Mapping44 because I could not find a system old
enough for me to test it.
- Go issue related to this: 23731
lib/tsan/go/buildgo.sh | ||
---|---|---|
60 | List of sources is completely identical to amd64 version, please don't duplicate it. Just keep it outside of the arch if. | |
lib/tsan/rtl/tsan_platform.h | ||
445 | kLoAppMemEnd is 0x010000000000ull, please adjust this line. | |
448 | remove this line | |
464 | I don't see where/how this is used. | |
468 | What lives in kHiAppMemBeg-kHiAppMemEnd range? | |
472 | I don't see where/how this is used. | |
819 | This is full copy of the C++ mapping, right? | |
876–877 | Why? | |
lib/tsan/rtl/tsan_platform_linux.cc | ||
239 | No need to duplicate this call. vmaSize = (MostSignificantSetBitIndex(GET_CURRENT_FRAME()) + 1); ... # elif defined(__powerpc64__) # if !SANITIZER_GO if (vmaSize != 44 && vmaSize != 46 && vmaSize != 47) { ... } # else if (vmaSize != 44 && vmaSize != 46) { ... } # endif | |
lib/tsan/rtl/tsan_rtl.cc | ||
309 ↗ | (On Diff #141886) | These VPrintf's look redundant (and mis-aligned). We already print p, s and MemToMeta(p) few lines above. |
lib/tsan/rtl/tsan_platform.h | ||
---|---|---|
468 | ld.so and shared libraries. Actually, let me ask you about this, since it seems I'm understanding wrongly how this should work. Is it necessary to map these memory areas for shared libraries? Or just executable/heap/shadow/meta are enough for the Go sanitizer? |
lib/tsan/rtl/tsan_platform.h | ||
---|---|---|
468 | For Go we care about and only need shadow for Go's heap and data/bss segment. All other addresses never passed to tsan runtime, they are filtered here: So I think we don't need vdso, HiAppMem and HeapMem, we probably need something closer to x86_64 Go mapping. |
lib/tsan/rtl/tsan_platform.h | ||
---|---|---|
468 | Excellent, thanks! I'll make the changes and resubmit. |
Much nicer now!
I think this is ready for commit after fixing these few nits.
lib/tsan/go/buildgo.sh | ||
---|---|---|
59 | If I am reading this correctly, amd64 will not have -fPIC because this overrides whole OSCFLAGS rather than append to them. Do we need something like: OSCFLAGS="$OSCFLAGS -ffreestanding -Wno-unused-const-variable -Werror -Wno-unknown-warning-option" ? | |
lib/tsan/rtl/tsan_platform.h | ||
414 | This should be: 0000 0000 1000 - 0000 1000 0000 | |
438 | This should be: 0000 0000 1000 - 0000 1000 0000 |
Version 3: fixed OSCFLAGS for amd64 in buildgo.sh and some comments in tsan_platform.h.
Could you please do it? I don't have commit access. Thanks!
lib/tsan/go/buildgo.sh | ||
---|---|---|
59 | Oops... sorry about that. |
Submitted in:
http://llvm.org/viewvc/llvm-project?view=revision&revision=330122
Thanks!
If I am reading this correctly, amd64 will not have -fPIC because this overrides whole OSCFLAGS rather than append to them. Do we need something like:
?