Don't pattern-init an unused variable that overallocates the stack
ART is intentionally walking to the stack top (lowest address), but the
pattern initialization is accidentally triggering a sanitizer failure
for an overflow. Removing the pattern initialization from that unused
(and uninitialized) variable restores the original functionality of
accessing every page of the available stack.
Fixes: 148125929
Bug: 131390872
Test: m checkbuild ASAN_OPTIONS=detect_leaks=0 SANITIZE_HOST=address
Change-Id: I2b1e8bdc44044e8165a14a8e7b36dd8616d4a5b3
diff --git a/runtime/thread.cc b/runtime/thread.cc
index c3e4afe..2319f89 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -790,7 +790,9 @@
#else
1u;
#endif
- volatile char space[kPageSize - (kAsanMultiplier * 256)];
+ // Keep space uninitialized as it can overflow the stack otherwise (should Clang actually
+ // auto-initialize this local variable).
+ volatile char space[kPageSize - (kAsanMultiplier * 256)] __attribute__((uninitialized));
char sink ATTRIBUTE_UNUSED = space[zero]; // NOLINT
// Remove tag from the pointer. Nop in non-hwasan builds.
uintptr_t addr = reinterpret_cast<uintptr_t>(__hwasan_tag_pointer(space, 0));