Skip to content

Conversation

@Camsyn
Copy link
Contributor

@Camsyn Camsyn commented Jul 24, 2025

Supplement to PR #144073

Previously, msan_check_mem_is_initialized.cpp initialized a 32-byte stack array, but checked the shadow for the offset range [12, 42), exceeding the stack array size.

MSan does not guarantee that the shadow corresponding to the overflow part is 0, so it is undefined to require the overflow part to be unpoisoned.

Previously, msan_check_mem_is_initialized.cpp initialized a stack array
with size of 32-byte, but check the shaodw for offset range [12, 42),
exceeding the stack array size.

MSan does not guarantee that the shadow corresponding to the overflow
part  is 0, so it is undefined to require the overflow part to be
unpoisoned
@llvmbot
Copy link
Member

llvmbot commented Jul 24, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Kunqiu Chen (Camsyn)

Changes

Supplement to PR #144073

Previously, msan_check_mem_is_initialized.cpp initialized a 32-byte stack array, but checked the shadow for the offset range [12, 42), exceeding the stack array size.

MSan does not guarantee that the shadow corresponding to the overflow part is 0, so it is undefined to require the overflow part to be unpoisoned.


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

1 Files Affected:

  • (modified) compiler-rt/test/msan/msan_check_mem_is_initialized.cpp (+1-1)
diff --git a/compiler-rt/test/msan/msan_check_mem_is_initialized.cpp b/compiler-rt/test/msan/msan_check_mem_is_initialized.cpp
index aaf5737ebe236..aab31893e01bc 100644
--- a/compiler-rt/test/msan/msan_check_mem_is_initialized.cpp
+++ b/compiler-rt/test/msan/msan_check_mem_is_initialized.cpp
@@ -12,7 +12,7 @@ int main(void) {
   __msan_poison(p + 10, 2);
 
   __msan_check_mem_is_initialized(p, 10);
-  __msan_check_mem_is_initialized(p + 12, 30);
+  __msan_check_mem_is_initialized(p + 12, 20);
 #ifdef POSITIVE
   __msan_check_mem_is_initialized(p + 5, 20);
   // CHECK: Uninitialized bytes in __msan_check_mem_is_initialized at offset 5 inside [0x{{.*}}, 20)

Copy link
Contributor

@fmayer fmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

Did this cause test failures for you?

@Camsyn
Copy link
Contributor Author

Camsyn commented Jul 24, 2025

Did this cause test failures for you?

I am implementing a sanitizer composition framework, which intends to support ASan, TSan and MSan.

This test failed in the scenario of -fsanitize=address,memory, where ASan modifies the size of this stack array.

@Camsyn Camsyn merged commit 84dc97e into llvm:main Jul 25, 2025
13 checks passed
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
Supplement to PR llvm#144073

Previously, _msan_check_mem_is_initialized.cpp_ initialized a 32-byte
stack array, but checked the shadow for the offset range [12, 42),
exceeding the stack array size.

MSan does not guarantee that the shadow corresponding to the overflow
part is 0, so it is undefined to require the overflow part to be
unpoisoned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants