Bug 86759 - ThreadSanitizer: unsupported VMA range on ppc64le
Summary: ThreadSanitizer: unsupported VMA range on ppc64le
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-31 17:55 UTC by Marek Polacek
Modified: 2018-08-01 18:21 UTC (History)
3 users (show)

See Also:
Host:
Target: ppc64le
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-08-01 00:00:00


Attachments
fix (1.46 KB, patch)
2018-08-01 15:08 UTC, Marek Polacek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Polacek 2018-07-31 17:55:22 UTC
TSan doesn't seem to work on ppc64le with kernel-4.14:

x.c:
int main () { }

# ./xgcc -B. -B ../powerpc64le-unknown-linux-gnu/libsanitizer/tsan/ -B ../powerpc64le-unknown-linux-gnu/libsanitizer/tsan/.libs/ -Wl,-rpath=../powerpc64le-unknown-linux-gnu/libsanitizer/tsan/.libs/ x.c -fsanitize=thread
# ./a.out 
FATAL: ThreadSanitizer: unsupported VMA range
FATAL: Found 47 - Supported 44 and 46

Target: powerpc64le-unknown-linux-gnu
Configured with: /root/gcc/configure --enable-languages=c,c++ --enable-checking=yes -with-system-zlib --disable-bootstrap --disable-libvtv --disable-libitm --disable-libgomp --disable-libcc1 --disable-libstdcxx-pch --disable-libssp --disable-isl --disable-libmpx
Thread model: posix
gcc version 9.0.0 20180731 (experimental) (GCC)
Comment 1 Martin Liška 2018-08-01 12:26:09 UTC
Fixed on trunk in libsanitizer:
https://reviews.llvm.org/D39924

Thus libsanitizer update will fix that.
Comment 2 Jakub Jelinek 2018-08-01 13:19:31 UTC
I think we can just cherry-pick that to trunk and perhaps 8.3 too (for full merge from libsanitizer I'd rather wait for later, say October).
Comment 3 Marek Polacek 2018-08-01 15:08:26 UTC
Created attachment 44482 [details]
fix

Fix I'm testing
Comment 4 Marek Polacek 2018-08-01 15:21:04 UTC
We actually also need

commit 4b8cb24bb7cf820f095b20edaa5812d4b78189a4
Author: Bill Seurer <seurer@linux.vnet.ibm.com>
Date:   Tue Nov 28 16:28:54 2017 +0000

    [PowerPC][tsan] Update tsan to handle changed memory layouts in newer kernels
    
    In more recent Linux kernels with 47 bit VMAs the layout of virtual memory
    for powerpc64 changed causing the thread sanitizer to not work properly. This
    patch adds support for 47 bit VMA kernels for powerpc64.
    
    (second part)
    
    Tested on several 4.x and 3.x kernel releases.
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319180 91177308-0d34-0410-b5e6-96231b3b80d8

diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
index 216eef93c..e14d5f575 100644
--- a/lib/tsan/rtl/tsan_platform_linux.cc
+++ b/lib/tsan/rtl/tsan_platform_linux.cc
@@ -217,9 +217,9 @@ void InitializePlatformEarly() {
     Die();
   }
 #elif defined(__powerpc64__)
-  if (vmaSize != 44 && vmaSize != 46) {
+  if (vmaSize != 44 && vmaSize != 46 && vmaSize != 47) {
     Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
-    Printf("FATAL: Found %d - Supported 44 and 46\n", vmaSize);
+    Printf("FATAL: Found %d - Supported 44, 46, and 47\n", vmaSize);
     Die();
   }
 #endif
Comment 5 Marek Polacek 2018-08-01 17:18:01 UTC
Author: mpolacek
Date: Wed Aug  1 17:17:29 2018
New Revision: 263229

URL: https://gcc.gnu.org/viewcvs?rev=263229&root=gcc&view=rev
Log:
Cherry-pick compiler-rt revision 318044 and 319180.

    [PowerPC][tsan] Update tsan to handle changed memory layouts in newer kernels
    
    In more recent Linux kernels with 47 bit VMAs the layout of virtual memory
    for powerpc64 changed causing the thread sanitizer to not work properly. This
    patch adds support for 47 bit VMA kernels for powerpc64.
    
    Tested on several 4.x and 3.x kernel releases.

Regtested/bootstrapped on ppc64le-linux with kernel 4.14; applying to
trunk/8.3.

2018-08-01  Marek Polacek  <polacek@redhat.com>

	PR sanitizer/86759
	* tsan/tsan_platform.h: Cherry-pick compiler-rt revision 318044.
	* tsan/tsan_platform_linux.cc: Cherry-pick compiler-rt revision
	319180.


Modified:
    trunk/libsanitizer/ChangeLog
    trunk/libsanitizer/tsan/tsan_platform.h
    trunk/libsanitizer/tsan/tsan_platform_linux.cc
Comment 6 Jakub Jelinek 2018-08-01 18:18:01 UTC
Author: jakub
Date: Wed Aug  1 18:17:29 2018
New Revision: 263231

URL: https://gcc.gnu.org/viewcvs?rev=263231&root=gcc&view=rev
Log:
	PR sanitizer/86759
	* tsan/tsan_platform.h: Cherry-pick compiler-rt revision 318044.
	* tsan/tsan_platform_linux.cc: Cherry-pick compiler-rt revision
	319180.

Modified:
    branches/gcc-8-branch/libsanitizer/ChangeLog
    branches/gcc-8-branch/libsanitizer/tsan/tsan_platform.h
    branches/gcc-8-branch/libsanitizer/tsan/tsan_platform_linux.cc
Comment 7 Marek Polacek 2018-08-01 18:21:52 UTC
Fixed.