Skip to content

[asan] Print diagnostic if unlimited stack size detected #133170

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
merged 3 commits into from
Mar 27, 2025

Conversation

thurstond
Copy link
Contributor

This adds a diagnostic message if the stack size is unlimited. This would have simplified the diagnosis of
google/sanitizers#856 (comment); we anticipate this may help diagnose future issues too.

This adds a diagnostic message if the stack size is unlimited. This
would have simplified the diagnosis of
google/sanitizers#856 (comment);
we anticipate this may help diagnose future issues too.
@llvmbot
Copy link
Member

llvmbot commented Mar 26, 2025

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

Author: Thurston Dang (thurstond)

Changes

This adds a diagnostic message if the stack size is unlimited. This would have simplified the diagnosis of
google/sanitizers#856 (comment); we anticipate this may help diagnose future issues too.


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

1 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_rtl.cpp (+12)
diff --git a/compiler-rt/lib/asan/asan_rtl.cpp b/compiler-rt/lib/asan/asan_rtl.cpp
index 19c6c210b564c..d98b350828448 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -451,6 +451,18 @@ static bool AsanInitInternal() {
 
   DisableCoreDumperIfNecessary();
 
+#if SANITIZER_POSIX
+  if (StackSizeIsUnlimited()) {
+    VPrintf(1,
+            "WARNING: Unlimited stack size detected. This may affect "
+            "compatibility with the shadow mappings.\n");
+    // MSan and TSan re-exec with a fixed size stack. We don't do that because
+    // it may break the program. InitializeShadowMemory() will, if needed,
+    // re-exec without ASLR, which solves most shadow mapping compatibility
+    // issues.
+  }
+#endif
+
   InitializeShadowMemory();
 
   AsanTSDInit(PlatformTSDDtor);

@thurstond thurstond merged commit e5ec87f into llvm:main Mar 27, 2025
10 checks passed
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