Revision: 21273
Author:   [email protected]
Date:     Mon May 12 19:32:12 2014 UTC
Log: v8::TryCatch now works correctly with ASAN's UseAfterReturn mode enabled.

BUG=chromium:369962
LOG=N
[email protected]

Review URL: https://codereview.chromium.org/273383003
http://code.google.com/p/v8/source/detail?r=21273

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/src/base/macros.h
 /branches/bleeding_edge/src/isolate.cc
 /branches/bleeding_edge/src/zone.h

=======================================
--- /branches/bleeding_edge/include/v8.h        Mon May 12 07:41:06 2014 UTC
+++ /branches/bleeding_edge/include/v8.h        Mon May 12 19:32:12 2014 UTC
@@ -5076,6 +5076,8 @@
   void SetCaptureMessage(bool value);

  private:
+  TryCatch* DesanitizedThis();
+
   // Make it hard to create heap-allocated TryCatch blocks.
   TryCatch(const TryCatch&);
   void operator=(const TryCatch&);
@@ -5087,6 +5089,7 @@
   void* exception_;
   void* message_obj_;
   void* message_script_;
+  void* asan_fake_stack_handle_;
   int message_start_pos_;
   int message_end_pos_;
   bool is_verbose_ : 1;
=======================================
--- /branches/bleeding_edge/src/api.cc  Mon May 12 07:41:06 2014 UTC
+++ /branches/bleeding_edge/src/api.cc  Mon May 12 19:32:12 2014 UTC
@@ -6,6 +6,9 @@

 #include <string.h>  // For memcpy, strlen.
 #include <cmath>  // For isnan.
+#ifdef V8_USE_ADDRESS_SANITIZER
+#include <sanitizer/asan_interface.h>
+#endif  // V8_USE_ADDRESS_SANITIZER
 #include "../include/v8-debug.h"
 #include "../include/v8-profiler.h"
 #include "../include/v8-testing.h"
@@ -1817,6 +1820,16 @@
     isolate_->UnregisterTryCatchHandler(this);
   }
 }
+
+
+v8::TryCatch* v8::TryCatch::DesanitizedThis() {
+#ifdef V8_USE_ADDRESS_SANITIZER
+  return TRY_CATCH_FROM_ADDRESS(
+ __asan_addr_is_in_fake_stack(asan_fake_stack_handle_, this, NULL, NULL));
+#else
+  return this;
+#endif
+}


 bool v8::TryCatch::HasCaught() const {
@@ -1893,6 +1906,11 @@
   message_script_ = the_hole;
   message_start_pos_ = 0;
   message_end_pos_ = 0;
+#ifdef V8_USE_ADDRESS_SANITIZER
+  asan_fake_stack_handle_ = __asan_get_current_fake_stack();
+#else
+  asan_fake_stack_handle_ = NULL;
+#endif
 }


=======================================
--- /branches/bleeding_edge/src/base/macros.h   Tue Apr 29 06:42:26 2014 UTC
+++ /branches/bleeding_edge/src/base/macros.h   Mon May 12 19:32:12 2014 UTC
@@ -54,15 +54,17 @@
 #define MUST_USE_RESULT V8_WARN_UNUSED_RESULT


-// Define DISABLE_ASAN macros.
+// Define V8_USE_ADDRESS_SANITIZER macros.
 #if defined(__has_feature)
 #if __has_feature(address_sanitizer)
-#define DISABLE_ASAN __attribute__((no_sanitize_address))
+#define V8_USE_ADDRESS_SANITIZER 1
 #endif
 #endif

-
-#ifndef DISABLE_ASAN
+// Define DISABLE_ASAN macros.
+#ifdef V8_USE_ADDRESS_SANITIZER
+#define DISABLE_ASAN __attribute__((no_sanitize_address))
+#else
 #define DISABLE_ASAN
 #endif

=======================================
--- /branches/bleeding_edge/src/isolate.cc      Fri May  9 09:13:12 2014 UTC
+++ /branches/bleeding_edge/src/isolate.cc      Mon May 12 19:32:12 2014 UTC
@@ -272,13 +272,14 @@
   // JS stack.  When running without the simulator, the address
   // returned will be the address of the C++ try catch handler itself.
   Address address = reinterpret_cast<Address>(
- SimulatorStack::RegisterCTryCatch(reinterpret_cast<uintptr_t>(that)));
+      SimulatorStack::RegisterCTryCatch(reinterpret_cast<uintptr_t>(
+          that->DesanitizedThis())));
   thread_local_top()->set_try_catch_handler_address(address);
 }


 void Isolate::UnregisterTryCatchHandler(v8::TryCatch* that) {
-  ASSERT(thread_local_top()->TryCatchHandler() == that);
+  ASSERT(thread_local_top()->TryCatchHandler() == that->DesanitizedThis());
   thread_local_top()->set_try_catch_handler_address(
       reinterpret_cast<Address>(that->next_));
   thread_local_top()->catcher_ = NULL;
=======================================
--- /branches/bleeding_edge/src/zone.h  Tue Apr 29 06:42:26 2014 UTC
+++ /branches/bleeding_edge/src/zone.h  Mon May 12 19:32:12 2014 UTC
@@ -15,11 +15,6 @@
 namespace v8 {
 namespace internal {

-#if defined(__has_feature)
-  #if __has_feature(address_sanitizer)
-    #define V8_USE_ADDRESS_SANITIZER
-  #endif
-#endif

 class Segment;
 class Isolate;

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to