Skip to content

[Sanitizer][Ignorelist] Expanding =sanitize to global. #142456

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

qinkunbao
Copy link
Member

See #139128
If multiple entries match the source, than the latest entry takes the
precedence.`

qinkunbao added 2 commits June 2, 2025 18:58
Created using spr 1.3.6
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jun 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 2, 2025

@llvm/pr-subscribers-clang

Author: Qinkun Bao (qinkunbao)

Changes

See #139128
If multiple entries match the source, than the latest entry takes the
precedence.`


Full diff: https://github.com/llvm/llvm-project/pull/142456.diff

1 Files Affected:

  • (added) clang/test/CodeGen/ubsan-global-ignorelist.test (+39)
diff --git a/clang/test/CodeGen/ubsan-global-ignorelist.test b/clang/test/CodeGen/ubsan-global-ignorelist.test
new file mode 100644
index 0000000000000..8d7812217f331
--- /dev/null
+++ b/clang/test/CodeGen/ubsan-global-ignorelist.test
@@ -0,0 +1,39 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
+// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds -fsanitize-ignorelist=%t/order-0.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
+// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds -fsanitize-ignorelist=%t/order-1.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
+// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds -fsanitize-ignorelist=%t/order-2.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
+// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds -fsanitize-ignorelist=%t/order-3.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
+
+// The same type can appear multiple times within an ignorelist. Any ``=sanitize`` type
+// entries enable sanitizer instrumentation, even if it was ignored by entries before.
+// If multiple entries match the source, then the latest entry takes the
+// precedence.
+
+//--- order-0.ignorelist
+global:global_array
+
+//--- order-1.ignorelist
+global:global_array
+global:global_array=sanitize
+
+//--- order-2.ignorelist
+global:*
+global:global_array=sanitize
+global:global_array
+
+//--- order-3.ignorelist
+global:*
+global:global_array=sanitize
+global:global*
+global:*array=sanitize
+
+//--- test.c
+unsigned global_array[100] = {-1};
+
+// CHECK-LABEL: define dso_local i32 @test
+// IGNORE-NOT: call void @__ubsan_handle_out_of_bounds
+// SANITIZE: call void @__ubsan_handle_out_of_bounds
+int test(int i) { return global_array[i]; }

qinkunbao added 2 commits June 2, 2025 19:10
Created using spr 1.3.6
Created using spr 1.3.6
@llvmbot llvmbot added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Jun 2, 2025
@qinkunbao qinkunbao changed the title [UBSan][Ignorelist] Expanding =sanitize to global. [Sanitizer][Ignorelist] Expanding =sanitize to global. Jun 2, 2025
@qinkunbao qinkunbao requested a review from vitalybuka June 2, 2025 20:04
@qinkunbao qinkunbao changed the base branch from users/qinkunbao/spr/main.ubsanignorelist-expanding-sanitize-to-global-1 to main June 2, 2025 21:08
@qinkunbao qinkunbao merged commit 43c2234 into main Jun 2, 2025
7 of 10 checks passed
@qinkunbao qinkunbao deleted the users/qinkunbao/spr/ubsanignorelist-expanding-sanitize-to-global-1 branch June 2, 2025 21:47
sallto pushed a commit to sallto/llvm-project that referenced this pull request Jun 3, 2025
See llvm#139128
If multiple entries match the source, than the latest entry takes the
precedence.`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants