-
Notifications
You must be signed in to change notification settings - Fork 809
Disable "downcast of address" UBSAN runtime error #6448
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
Merged
dnovillo
merged 2 commits into
microsoft:main
from
amaiorano:disable-ubsan-failure-on-create-sentinel
Mar 22, 2024
Merged
Disable "downcast of address" UBSAN runtime error #6448
dnovillo
merged 2 commits into
microsoft:main
from
amaiorano:disable-ubsan-failure-on-create-sentinel
Mar 22, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a temporary workaround until we fix: microsoft#6446 This should allow us to enable asan/ubsan checks: microsoft#6428
Contributor
You can test this locally with the following command:git-clang-format --diff 7581ff4d297d124b340d6715b709f1c423909ca5 bba8e757d34fef6bc2a5b3283c5cafb8f5feb2fa -- include/llvm/ADT/SparseBitVector.h include/llvm/Analysis/IVUsers.h include/llvm/CodeGen/MachineBasicBlock.h include/llvm/CodeGen/MachineFunction.h include/llvm/CodeGen/SelectionDAG.h include/llvm/CodeGen/SlotIndexes.h include/llvm/IR/BasicBlock.h include/llvm/IR/Function.h include/llvm/IR/Instruction.h include/llvm/IR/Module.h include/llvm/Transforms/Utils/SymbolRewriter.h tools/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.hView the diff from clang-format here.diff --git a/include/llvm/ADT/SparseBitVector.h b/include/llvm/ADT/SparseBitVector.h
index 755de82e..7b4fbc8d 100644
--- a/include/llvm/ADT/SparseBitVector.h
+++ b/include/llvm/ADT/SparseBitVector.h
@@ -254,10 +254,13 @@ struct ilist_traits<SparseBitVectorElement<ElementSize> >
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- Element *createSentinel() const { return static_cast<Element *>(&Sentinel); }
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ Element *
+ createSentinel() const {
+ return static_cast<Element *>(&Sentinel);
+ }
static void destroySentinel(Element *) {}
Element *provideInitialHead() const { return createSentinel(); }
diff --git a/include/llvm/Analysis/IVUsers.h b/include/llvm/Analysis/IVUsers.h
index 3c43eb4e..a5be928b 100644
--- a/include/llvm/Analysis/IVUsers.h
+++ b/include/llvm/Analysis/IVUsers.h
@@ -102,10 +102,11 @@ template<> struct ilist_traits<IVStrideUse>
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- IVStrideUse *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ IVStrideUse *
+ createSentinel() const {
// since i(p)lists always publicly derive from the corresponding
// traits, placing a data member in this class will augment i(p)list.
// But since the NodeTy is expected to publicly derive from
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h
index 12bf8257..b5ddf38d 100644
--- a/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/include/llvm/CodeGen/MachineBasicBlock.h
@@ -46,10 +46,11 @@ public:
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- MachineInstr *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ MachineInstr *
+ createSentinel() const {
return static_cast<MachineInstr*>(&Sentinel);
}
void destroySentinel(MachineInstr *) const {}
diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h
index 47463b12..9886cba4 100644
--- a/include/llvm/CodeGen/MachineFunction.h
+++ b/include/llvm/CodeGen/MachineFunction.h
@@ -54,10 +54,11 @@ public:
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- MachineBasicBlock *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ MachineBasicBlock *
+ createSentinel() const {
return static_cast<MachineBasicBlock*>(&Sentinel);
}
void destroySentinel(MachineBasicBlock *) const {}
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h
index 363400c8..e35d8a8a 100644
--- a/include/llvm/CodeGen/SelectionDAG.h
+++ b/include/llvm/CodeGen/SelectionDAG.h
@@ -90,10 +90,11 @@ public:
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- SDNode *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ SDNode *
+ createSentinel() const {
return static_cast<SDNode*>(&Sentinel);
}
static void destroySentinel(SDNode *) {}
diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h
index 4a2515fd..125602dd 100644
--- a/include/llvm/CodeGen/SlotIndexes.h
+++ b/include/llvm/CodeGen/SlotIndexes.h
@@ -74,16 +74,17 @@ namespace llvm {
private:
mutable ilist_half_node<IndexListEntry> Sentinel;
public:
-// HLSL Change Starts
-// Temporarily disable "downcast of address" UBSAN runtime error
-// https://github.com/microsoft/DirectXShaderCompiler/issues/6446
+ // HLSL Change Starts
+ // Temporarily disable "downcast of address" UBSAN runtime error
+ // https://github.com/microsoft/DirectXShaderCompiler/issues/6446
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
- __attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- IndexListEntry *createSentinel() const {
+ __attribute__((no_sanitize("undefined")))
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ IndexListEntry *
+ createSentinel() const {
return static_cast<IndexListEntry*>(&Sentinel);
}
void destroySentinel(IndexListEntry *) const {}
diff --git a/include/llvm/IR/BasicBlock.h b/include/llvm/IR/BasicBlock.h
index 89a2435b..89d9aa3a 100644
--- a/include/llvm/IR/BasicBlock.h
+++ b/include/llvm/IR/BasicBlock.h
@@ -347,11 +347,12 @@ private:
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
// HLSL Change Ends
-inline BasicBlock *ilist_traits<BasicBlock>::createSentinel() const {
- return static_cast<BasicBlock*>(&Sentinel);
+inline BasicBlock *
+ilist_traits<BasicBlock>::createSentinel() const {
+ return static_cast<BasicBlock *>(&Sentinel);
}
// Create wrappers for C Binding types (see CBindingWrapping.h).
diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h
index 8d2ad201..935e9339 100644
--- a/include/llvm/IR/Function.h
+++ b/include/llvm/IR/Function.h
@@ -42,10 +42,11 @@ template<> struct ilist_traits<Argument>
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- Argument *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ Argument *
+ createSentinel() const {
return static_cast<Argument*>(&Sentinel);
}
static void destroySentinel(Argument*) {}
diff --git a/include/llvm/IR/Instruction.h b/include/llvm/IR/Instruction.h
index 7f4cde54..763ae730 100644
--- a/include/llvm/IR/Instruction.h
+++ b/include/llvm/IR/Instruction.h
@@ -521,10 +521,11 @@ private:
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
// HLSL Change Ends
-inline Instruction *ilist_traits<Instruction>::createSentinel() const {
+inline Instruction *
+ilist_traits<Instruction>::createSentinel() const {
// Since i(p)lists always publicly derive from their corresponding traits,
// placing a data member in this class will augment the i(p)list. But since
// the NodeTy is expected to be publicly derive from ilist_node<NodeTy>,
diff --git a/include/llvm/IR/Module.h b/include/llvm/IR/Module.h
index 2404a119..38d12464 100644
--- a/include/llvm/IR/Module.h
+++ b/include/llvm/IR/Module.h
@@ -52,10 +52,11 @@ template<> struct ilist_traits<Function>
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- Function *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ Function *
+ createSentinel() const {
return static_cast<Function*>(&Sentinel);
}
static void destroySentinel(Function*) {}
@@ -77,10 +78,11 @@ template<> struct ilist_traits<GlobalVariable>
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- GlobalVariable *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ GlobalVariable *
+ createSentinel() const {
return static_cast<GlobalVariable*>(&Sentinel);
}
static void destroySentinel(GlobalVariable*) {}
@@ -101,10 +103,11 @@ template<> struct ilist_traits<GlobalAlias>
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- GlobalAlias *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ GlobalAlias *
+ createSentinel() const {
return static_cast<GlobalAlias*>(&Sentinel);
}
static void destroySentinel(GlobalAlias*) {}
@@ -126,10 +129,11 @@ template<> struct ilist_traits<NamedMDNode>
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- NamedMDNode *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ NamedMDNode *
+ createSentinel() const {
return static_cast<NamedMDNode*>(&Sentinel);
}
static void destroySentinel(NamedMDNode*) {}
diff --git a/include/llvm/Transforms/Utils/SymbolRewriter.h b/include/llvm/Transforms/Utils/SymbolRewriter.h
index c17783bb..4eeb4f41 100644
--- a/include/llvm/Transforms/Utils/SymbolRewriter.h
+++ b/include/llvm/Transforms/Utils/SymbolRewriter.h
@@ -125,10 +125,11 @@ public:
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
__attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- SymbolRewriter::RewriteDescriptor *createSentinel() const {
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ SymbolRewriter::RewriteDescriptor *
+ createSentinel() const {
// since i[p] lists always publicly derive from the corresponding
// traits, placing a data member in this class will augment the
// i[p]list. Since the NodeTy is expected to publicly derive from
diff --git a/tools/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/tools/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index de48fa9c..f040147d 100644
--- a/tools/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/tools/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -317,16 +317,17 @@ public:
namespace llvm {
template<> struct ilist_traits<clang::ento::BugReport>
: public ilist_default_traits<clang::ento::BugReport> {
-// HLSL Change Starts
-// Temporarily disable "downcast of address" UBSAN runtime error
-// https://github.com/microsoft/DirectXShaderCompiler/issues/6446
+ // HLSL Change Starts
+ // Temporarily disable "downcast of address" UBSAN runtime error
+ // https://github.com/microsoft/DirectXShaderCompiler/issues/6446
#ifdef __has_feature
#if __has_feature(undefined_behavior_sanitizer)
- __attribute__((no_sanitize("undefined")))
-#endif // __has_feature(address_sanitizer)
-#endif // defined(__has_feature)
-// HLSL Change Ends
- clang::ento::BugReport *createSentinel() const {
+ __attribute__((no_sanitize("undefined")))
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
+ // HLSL Change Ends
+ clang::ento::BugReport *
+ createSentinel() const {
return static_cast<clang::ento::BugReport *>(&Sentinel);
}
void destroySentinel(clang::ento::BugReport *) const {}
|
llvm-beanz
approved these changes
Mar 22, 2024
dnovillo
approved these changes
Mar 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a temporary workaround until we fix:
#6446
This should allow us to enable asan/ubsan checks:
#6428