-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
[NFC][sanitizer] Add checks for impossible state #108672
base: main
Are you sure you want to change the base?
[NFC][sanitizer] Add checks for impossible state #108672
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.