From: jochen@chromium.org Date: Tue, 7 Oct 2014 16:11:31 +0000 (+0000) Subject: Fix data race on Debug::thread_local_.current_debug_scope_ X-Git-Tag: upstream/4.7.83~6511 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be69c78e6dda611aeb0a5c5abc8c96efce25fc45;p=platform%2Fupstream%2Fv8.git Fix data race on Debug::thread_local_.current_debug_scope_ BUG=v8:3614 R=yangguo@chromium.org LOG=n Review URL: https://codereview.chromium.org/631223004 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24441 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/debug.cc b/src/debug.cc index cacc8e2..2329b25 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -563,7 +563,8 @@ void Debug::ThreadInit() { thread_local_.step_into_fp_ = 0; thread_local_.step_out_fp_ = 0; // TODO(isolates): frames_are_dropped_? - thread_local_.current_debug_scope_ = NULL; + base::NoBarrier_Store(&thread_local_.current_debug_scope_, + static_cast(NULL)); thread_local_.restarter_frame_function_pointer_ = NULL; } @@ -3089,7 +3090,8 @@ DebugScope::DebugScope(Debug* debug) no_termination_exceptons_(debug_->isolate_, StackGuard::TERMINATE_EXECUTION) { // Link recursive debugger entry. - debug_->thread_local_.current_debug_scope_ = this; + base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, + reinterpret_cast(this)); // Store the previous break id and frame id. break_id_ = debug_->break_id(); @@ -3126,7 +3128,8 @@ DebugScope::~DebugScope() { } // Leaving this debugger entry. - debug_->thread_local_.current_debug_scope_ = prev_; + base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, + reinterpret_cast(prev_)); // Restore to the previous break state. debug_->thread_local_.break_frame_id_ = break_frame_id_; diff --git a/src/debug.h b/src/debug.h index 9b14afc..a95ecf2 100644 --- a/src/debug.h +++ b/src/debug.h @@ -8,6 +8,7 @@ #include "src/allocation.h" #include "src/arguments.h" #include "src/assembler.h" +#include "src/base/atomicops.h" #include "src/base/platform/platform.h" #include "src/execution.h" #include "src/factory.h" @@ -459,7 +460,10 @@ class Debug { } // Flags and states. - DebugScope* debugger_entry() { return thread_local_.current_debug_scope_; } + DebugScope* debugger_entry() { + return reinterpret_cast( + base::NoBarrier_Load(&thread_local_.current_debug_scope_)); + } inline Handle debug_context() { return debug_context_; } void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; } bool live_edit_enabled() const { @@ -470,7 +474,7 @@ class Debug { inline bool is_loaded() const { return !debug_context_.is_null(); } inline bool has_break_points() const { return has_break_points_; } inline bool in_debug_scope() const { - return thread_local_.current_debug_scope_ != NULL; + return !!base::NoBarrier_Load(&thread_local_.current_debug_scope_); } void set_disable_break(bool v) { break_disabled_ = v; } @@ -599,7 +603,7 @@ class Debug { class ThreadLocal { public: // Top debugger entry. - DebugScope* current_debug_scope_; + base::AtomicWord current_debug_scope_; // Counter for generating next break id. int break_count_;