ART: Ensure minimum stack size under ASAN

When running sanitized, ensure a minimum stack size of 2MB to
ensure that classes in the core library can be initialized in
tests even under the access-checks interpreter.

Bug: 109813469
Test: SANITIZE_HOST=address art/test/testrunner/testrunner.py -b --host --interp-ac -t 004-ThreadStress -t 054 -t 107 -t 203 -t 924 -t 1905 -t 1907 -t 1907 -t 1912 -t 1913 -t 1914 -t 1916 -t 1917 -t 1920 -t 1921 -t 1930 -t 1931 -t 1932 -t 1935 -t 1936
Change-Id: I702d36552bbc753e286e619937370518aecf9692
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 7a7a80e..2f641df 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -504,6 +504,13 @@
   // so include that here to support apps that expect large native stacks.
   stack_size += 1 * MB;
 
+  // Under sanitization, frames of the interpreter may become bigger, both for C code as
+  // well as the ShadowFrame. Ensure a larger minimum size. Otherwise initialization
+  // of all core classes cannot be done in all test circumstances.
+  if (kMemoryToolIsAvailable) {
+    stack_size = std::max(2 * MB, stack_size);
+  }
+
   // It's not possible to request a stack smaller than the system-defined PTHREAD_STACK_MIN.
   if (stack_size < PTHREAD_STACK_MIN) {
     stack_size = PTHREAD_STACK_MIN;