Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Unified Diff: src/snapshot-external.cc

Issue 918213002: Protect access to the external_snapshot_blob global with a lock. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot-external.cc
diff --git a/src/snapshot-external.cc b/src/snapshot-external.cc
index f26a5a1c18dba7a2b43410e352778a1bf179d4b5..a9a5df1cd7c2a04f2c40a760c79ffb89a2b3742a 100644
--- a/src/snapshot-external.cc
+++ b/src/snapshot-external.cc
@@ -6,6 +6,7 @@
#include "src/snapshot.h"
+#include "src/base/platform/mutex.h"
#include "src/serialize.h"
#include "src/snapshot-source-sink.h"
#include "src/v8.h" // for V8::Initialize
@@ -19,9 +20,12 @@
namespace v8 {
namespace internal {
+static base::LazyMutex external_startup_data_mutex = LAZY_MUTEX_INITIALIZER;
static v8::StartupData external_startup_blob = {NULL, 0};
void SetSnapshotFromFile(StartupData* snapshot_blob) {
+ base::LockGuard<base::Mutex> lock_guard(
+ external_startup_data_mutex.Pointer());
DCHECK(snapshot_blob);
DCHECK(snapshot_blob->data);
DCHECK(snapshot_blob->raw_size > 0);
@@ -31,5 +35,9 @@ void SetSnapshotFromFile(StartupData* snapshot_blob) {
}
-const v8::StartupData Snapshot::SnapshotBlob() { return external_startup_blob; }
+const v8::StartupData Snapshot::SnapshotBlob() {
+ base::LockGuard<base::Mutex> lock_guard(
+ external_startup_data_mutex.Pointer());
+ return external_startup_blob;
+}
} } // namespace v8::internal
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698