summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Evgenii Stepanov <eugenis@google.com> 2016-11-17 17:57:25 -0800
committer Evgenii Stepanov <eugenis@google.com> 2016-11-17 17:58:00 -0800
commit1ffcf7b06fa301f6f1bd7d4d776387d4ecdcef1b (patch)
tree5a0ffcc6becddeb3b1f6e34c135ad0c760a74b65
parent137b07593aedfad193a77f3787ecf5197008c5da (diff)
Fix false positive stack ASan errors on x86.
Call a special ASan function in x86 DoLongJump to let the tool know that strange things are going to happen with the stack pointer. Other architectures do not need this because they do the stack pointer manipulation in a separate ((noreturn)) function, and noreturn attribute triggers the same conservative behaviour in ASan. Bug: 24199050 Bug: 32849425 Test: SANITIZE_HOST=address stub_test32 Change-Id: Ic639d2d84474d875487e66369c034db9907a7e8f
-rw-r--r--runtime/arch/x86/context_x86.cc2
-rw-r--r--runtime/base/memory_tool.h4
2 files changed, 6 insertions, 0 deletions
diff --git a/runtime/arch/x86/context_x86.cc b/runtime/arch/x86/context_x86.cc
index 077d2db870..cb3dfec5f5 100644
--- a/runtime/arch/x86/context_x86.cc
+++ b/runtime/arch/x86/context_x86.cc
@@ -17,6 +17,7 @@
#include "context_x86.h"
#include "base/bit_utils.h"
+#include "base/memory_tool.h"
#include "quick/quick_method_frame_info.h"
namespace art {
@@ -102,6 +103,7 @@ void X86Context::DoLongJump() {
uintptr_t esp = gprs[kNumberOfCpuRegisters - ESP - 1] - sizeof(intptr_t);
gprs[kNumberOfCpuRegisters] = esp;
*(reinterpret_cast<uintptr_t*>(esp)) = eip_;
+ MEMORY_TOOL_HANDLE_NO_RETURN;
__asm__ __volatile__(
"movl %1, %%ebx\n\t" // Address base of FPRs.
"movsd 0(%%ebx), %%xmm0\n\t" // Load up XMM0-XMM7.
diff --git a/runtime/base/memory_tool.h b/runtime/base/memory_tool.h
index e1a2e07aca..42cbaa0389 100644
--- a/runtime/base/memory_tool.h
+++ b/runtime/base/memory_tool.h
@@ -40,7 +40,10 @@ constexpr bool kMemoryToolIsAvailable = true;
constexpr bool kMemoryToolIsAvailable = false;
#endif
+extern "C" void __asan_handle_no_return();
+
#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
+#define MEMORY_TOOL_HANDLE_NO_RETURN __asan_handle_no_return()
#define RUNNING_ON_MEMORY_TOOL 1U
constexpr bool kMemoryToolIsValgrind = false;
constexpr bool kMemoryToolDetectsLeaks = true;
@@ -55,6 +58,7 @@ constexpr size_t kMemoryToolStackGuardSizeScale = 2;
#define MEMORY_TOOL_MAKE_UNDEFINED(p, s) VALGRIND_MAKE_MEM_UNDEFINED(p, s)
#define MEMORY_TOOL_MAKE_DEFINED(p, s) VALGRIND_MAKE_MEM_DEFINED(p, s)
#define ATTRIBUTE_NO_SANITIZE_ADDRESS
+#define MEMORY_TOOL_HANDLE_NO_RETURN do { } while (0)
#define RUNNING_ON_MEMORY_TOOL RUNNING_ON_VALGRIND
constexpr bool kMemoryToolIsAvailable = true;
constexpr bool kMemoryToolIsValgrind = true;