[NFC][sanitizer] Add checks for impossible state#108672
[NFC][sanitizer] Add checks for impossible state#108672vitalybuka wants to merge 25 commits intomainfrom
Conversation
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesI don't have reproducers, and don't know if this Before the patch: After the patch: Full diff: https://github.com/llvm/llvm-project/pull/108672.diff 1 Files Affected:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index c3c717bbdbe4c9..579d163479858c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -642,7 +642,7 @@ void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size,
if (!main) {
// If stack and tls intersect, make them non-intersecting.
if (*tls_addr > *stk_addr && *tls_addr < *stk_addr + *stk_size) {
- if (*stk_addr + *stk_size < *tls_addr + *tls_size)
+ if (*stk_addr + *stk_size > *tls_addr + *tls_size)
*tls_size = *stk_addr + *stk_size - *tls_addr;
*stk_size = *tls_addr - *stk_addr;
}
|
Created using spr 1.3.4 [skip ci]
|
I believe the intention was:
However, the case is invalid and impossible. If
I think this is a no-op.
This extension effect isn't needed. I think we can remove this statement. |
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4 [skip ci]
More aggressive checks |
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4 [skip ci]
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Put this into a comment. |
Before it was touched here afec953.
Important assumption that the stack is descending, but I don't think we
support ascending stack anyware.