-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[TySan] Make TySan compatible with UBSan #169036
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
Conversation
|
@llvm/pr-subscribers-clang-driver Author: Matthew Nagy (gbMattN) ChangesFull diff: https://github.com/llvm/llvm-project/pull/169036.diff 6 Files Affected:
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 420c4cddbc8dd..dfcc516f358b5 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -358,7 +358,7 @@ bool SanitizerArgs::needsFuzzerInterceptors() const {
bool SanitizerArgs::needsUbsanRt() const {
// All of these include ubsan.
if (needsAsanRt() || needsMsanRt() || needsNsanRt() || needsHwasanRt() ||
- needsTsanRt() || needsDfsanRt() || needsLsanRt() ||
+ needsTsanRt() || needsDfsanRt() || needsLsanRt() || needsTysanRt() ||
needsCfiCrossDsoDiagRt() || (needsScudoRt() && !requiresMinimalRuntime()))
return false;
diff --git a/compiler-rt/lib/tysan/CMakeLists.txt b/compiler-rt/lib/tysan/CMakeLists.txt
index 7d13ae3963919..bf0909455d0d8 100644
--- a/compiler-rt/lib/tysan/CMakeLists.txt
+++ b/compiler-rt/lib/tysan/CMakeLists.txt
@@ -72,7 +72,9 @@ else()
OBJECT_LIBS RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
+ RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
+ RTUbsan
CFLAGS ${TYSAN_CFLAGS}
PARENT_TARGET tysan)
endforeach()
diff --git a/compiler-rt/test/ubsan/CMakeLists.txt b/compiler-rt/test/ubsan/CMakeLists.txt
index 410585e6a07ef..f0b84f431472a 100644
--- a/compiler-rt/test/ubsan/CMakeLists.txt
+++ b/compiler-rt/test/ubsan/CMakeLists.txt
@@ -62,6 +62,9 @@ foreach(arch ${UBSAN_TEST_ARCH})
if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};" AND NOT ANDROID)
add_ubsan_testsuites("ThreadSanitizer" tsan ${arch})
endif()
+ if(COMPILER_RT_HAS_TYSAN AND ";${TYSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
+ add_ubsan_testsuites("TypeSanitizer" tysan ${arch})
+ endif()
endforeach()
macro(add_ubsan_device_testsuite test_mode sanitizer platform arch)
@@ -124,6 +127,10 @@ if(APPLE)
if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
add_ubsan_device_testsuite("ThreadSanitizer" tsan ${platform} ${arch})
endif()
+
+ if(COMPILER_RT_HAS_TYSAN AND ";${TYSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
+ add_ubsan_device_testsuite("TypeSanitizer" tysan ${platform} ${arch})
+ endif()
endforeach()
endforeach()
endif()
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp
index 0ab65bd30d92c..0b848ec8ac471 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp
@@ -7,6 +7,9 @@
// Reason unknown, needs debugging.
// UNSUPPORTED: target=aarch64{{.*}} && ubsan-tsan
+// TySan doesn't build a shared library
+// UNSUPPORTED: ubsan-tysan
+
#include <assert.h>
#include <signal.h>
#include <stdio.h>
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
index c6133178262cc..fd019d2242552 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
@@ -19,8 +19,9 @@
// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=edge,trace-pc-guard %s -o %t
// RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir='"%t-dir"' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
-// Coverage is not yet implemented in TSan.
+// Coverage is not yet implemented in TSan or TySan.
// XFAIL: ubsan-tsan
+// XFAIL: ubsan-tysan
// UNSUPPORTED: ubsan-standalone-static
// No coverage support
// UNSUPPORTED: target={{.*openbsd.*}}
diff --git a/compiler-rt/test/ubsan/lit.common.cfg.py b/compiler-rt/test/ubsan/lit.common.cfg.py
index 25e527903788e..314d207f94ad5 100644
--- a/compiler-rt/test/ubsan/lit.common.cfg.py
+++ b/compiler-rt/test/ubsan/lit.common.cfg.py
@@ -39,6 +39,9 @@ def get_required_attr(config, attr_name):
elif ubsan_lit_test_mode == "ThreadSanitizer":
config.available_features.add("ubsan-tsan")
clang_ubsan_cflags = ["-fsanitize=thread"]
+elif ubsan_lit_test_mode == "TypeSanitizer":
+ config.available_features.add("ubsan-tysan")
+ clang_ubsan_cflags = ["-fsanitize=type"]
else:
lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode)
|
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Matthew Nagy (gbMattN) ChangesFull diff: https://github.com/llvm/llvm-project/pull/169036.diff 6 Files Affected:
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 420c4cddbc8dd..dfcc516f358b5 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -358,7 +358,7 @@ bool SanitizerArgs::needsFuzzerInterceptors() const {
bool SanitizerArgs::needsUbsanRt() const {
// All of these include ubsan.
if (needsAsanRt() || needsMsanRt() || needsNsanRt() || needsHwasanRt() ||
- needsTsanRt() || needsDfsanRt() || needsLsanRt() ||
+ needsTsanRt() || needsDfsanRt() || needsLsanRt() || needsTysanRt() ||
needsCfiCrossDsoDiagRt() || (needsScudoRt() && !requiresMinimalRuntime()))
return false;
diff --git a/compiler-rt/lib/tysan/CMakeLists.txt b/compiler-rt/lib/tysan/CMakeLists.txt
index 7d13ae3963919..bf0909455d0d8 100644
--- a/compiler-rt/lib/tysan/CMakeLists.txt
+++ b/compiler-rt/lib/tysan/CMakeLists.txt
@@ -72,7 +72,9 @@ else()
OBJECT_LIBS RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
+ RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
+ RTUbsan
CFLAGS ${TYSAN_CFLAGS}
PARENT_TARGET tysan)
endforeach()
diff --git a/compiler-rt/test/ubsan/CMakeLists.txt b/compiler-rt/test/ubsan/CMakeLists.txt
index 410585e6a07ef..f0b84f431472a 100644
--- a/compiler-rt/test/ubsan/CMakeLists.txt
+++ b/compiler-rt/test/ubsan/CMakeLists.txt
@@ -62,6 +62,9 @@ foreach(arch ${UBSAN_TEST_ARCH})
if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};" AND NOT ANDROID)
add_ubsan_testsuites("ThreadSanitizer" tsan ${arch})
endif()
+ if(COMPILER_RT_HAS_TYSAN AND ";${TYSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
+ add_ubsan_testsuites("TypeSanitizer" tysan ${arch})
+ endif()
endforeach()
macro(add_ubsan_device_testsuite test_mode sanitizer platform arch)
@@ -124,6 +127,10 @@ if(APPLE)
if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
add_ubsan_device_testsuite("ThreadSanitizer" tsan ${platform} ${arch})
endif()
+
+ if(COMPILER_RT_HAS_TYSAN AND ";${TYSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
+ add_ubsan_device_testsuite("TypeSanitizer" tysan ${platform} ${arch})
+ endif()
endforeach()
endforeach()
endif()
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp
index 0ab65bd30d92c..0b848ec8ac471 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp
@@ -7,6 +7,9 @@
// Reason unknown, needs debugging.
// UNSUPPORTED: target=aarch64{{.*}} && ubsan-tsan
+// TySan doesn't build a shared library
+// UNSUPPORTED: ubsan-tysan
+
#include <assert.h>
#include <signal.h>
#include <stdio.h>
diff --git a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
index c6133178262cc..fd019d2242552 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
@@ -19,8 +19,9 @@
// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=edge,trace-pc-guard %s -o %t
// RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir='"%t-dir"' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
-// Coverage is not yet implemented in TSan.
+// Coverage is not yet implemented in TSan or TySan.
// XFAIL: ubsan-tsan
+// XFAIL: ubsan-tysan
// UNSUPPORTED: ubsan-standalone-static
// No coverage support
// UNSUPPORTED: target={{.*openbsd.*}}
diff --git a/compiler-rt/test/ubsan/lit.common.cfg.py b/compiler-rt/test/ubsan/lit.common.cfg.py
index 25e527903788e..314d207f94ad5 100644
--- a/compiler-rt/test/ubsan/lit.common.cfg.py
+++ b/compiler-rt/test/ubsan/lit.common.cfg.py
@@ -39,6 +39,9 @@ def get_required_attr(config, attr_name):
elif ubsan_lit_test_mode == "ThreadSanitizer":
config.available_features.add("ubsan-tsan")
clang_ubsan_cflags = ["-fsanitize=thread"]
+elif ubsan_lit_test_mode == "TypeSanitizer":
+ config.available_features.add("ubsan-tysan")
+ clang_ubsan_cflags = ["-fsanitize=type"]
else:
lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode)
|
🐧 Linux x64 Test Results
|
fhahn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
llvm/docs/ReleaseNotes.md
Outdated
| Changes to Sanitizers | ||
| --------------------- | ||
|
|
||
| * Support running TypeSanitizer with UndefinedBehaviourSanitizer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Support running TypeSanitizer with UndefinedBehaviourSanitizer | |
| * Support running TypeSanitizer with UndefinedBehaviourSanitizer. |
nit: for consistency with the list item below
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/19604 Here is the relevant piece of the build log for the reference |
|
Possibly unrelated by we've had test failures in the UBSan test suite since this landed: https://ci.swift.org/job/llvm.org/job/clang-stage1-RA-as/3614/testReport/junit/UBSan-TypeSanitizer-arm64/TestCases_Misc_Posix/print_stack_trace_cpp/ |
|
Hmm, from looking at the test I feel like this should have failed on the premerge tests... rather odd that it didn't. |
|
Thanks! Feel free to tag me as a reviewer. |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/17523 Here is the relevant piece of the build log for the reference |
No description provided.