From 2a62cce170b98d6d075d62e24b081631cf78d459 Mon Sep 17 00:00:00 2001 From: "ishell@chromium.org" Date: Tue, 20 May 2014 10:13:46 +0000 Subject: [PATCH] Reland "v8::TryCatch now works correctly with ASAN's UseAfterReturn mode enabled." BUG=chromium:369962 LOG=N R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/282783004 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21382 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8.h | 19 ++++++++++++++++++- src/api.cc | 21 ++++++++++++++++++++- src/arm/simulator-arm.h | 7 ------- src/arm64/simulator-arm64.h | 7 ------- src/base/macros.h | 14 ++++++++------ src/ia32/simulator-ia32.h | 3 --- src/isolate.cc | 26 ++++++-------------------- src/isolate.h | 15 +++++++++------ src/mips/simulator-mips.h | 7 ------- src/x64/simulator-x64.h | 3 --- src/zone.h | 5 ----- 11 files changed, 61 insertions(+), 66 deletions(-) diff --git a/include/v8.h b/include/v8.h index 94b7fa1500..8c2aaf9ca6 100644 --- a/include/v8.h +++ b/include/v8.h @@ -5076,6 +5076,22 @@ class V8_EXPORT TryCatch { */ void SetCaptureMessage(bool value); + /** + * There are cases when the raw address of C++ TryCatch object cannot be + * used for comparisons with addresses into the JS stack. The cases are: + * 1) ARM, ARM64 and MIPS simulators which have separate JS stack. + * 2) Address sanitizer allocates local C++ object in the heap when + * UseAfterReturn mode is enabled. + * This method returns address that can be used for comparisons with + * addresses into the JS stack. When neither simulator nor ASAN's + * UseAfterReturn is enabled, then the address returned will be the address + * of the C++ try catch handler itself. + */ + static void* JSStackComparableAddress(v8::TryCatch* handler) { + if (handler == NULL) return NULL; + return handler->js_stack_comparable_address_; + } + private: // Make it hard to create heap-allocated TryCatch blocks. TryCatch(const TryCatch&); @@ -5084,10 +5100,11 @@ class V8_EXPORT TryCatch { void operator delete(void*, size_t); v8::internal::Isolate* isolate_; - void* next_; + v8::TryCatch* next_; void* exception_; void* message_obj_; void* message_script_; + void* js_stack_comparable_address_; int message_start_pos_; int message_end_pos_; bool is_verbose_ : 1; diff --git a/src/api.cc b/src/api.cc index 4b305b002d..be2ac096d4 100644 --- a/src/api.cc +++ b/src/api.cc @@ -6,6 +6,9 @@ #include // For memcpy, strlen. #include // For isnan. +#ifdef V8_USE_ADDRESS_SANITIZER +#include +#endif // V8_USE_ADDRESS_SANITIZER #include "../include/v8-debug.h" #include "../include/v8-profiler.h" #include "../include/v8-testing.h" @@ -37,6 +40,7 @@ #include "runtime.h" #include "runtime-profiler.h" #include "scanner-character-streams.h" +#include "simulator.h" #include "snapshot.h" #include "unicode-inl.h" #include "utils/random-number-generator.h" @@ -1785,13 +1789,26 @@ Local