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

Side by Side Diff: src/snapshot/mksnapshot.cc

Issue 2808253002: Tell MSan to ignore uninitialized padding when writing snapshots (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <signal.h> 6 #include <signal.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/libplatform/libplatform.h" 9 #include "include/libplatform/libplatform.h"
10 #include "src/assembler.h" 10 #include "src/assembler.h"
11 #include "src/base/platform/platform.h" 11 #include "src/base/platform/platform.h"
12 #include "src/flags.h" 12 #include "src/flags.h"
13 #include "src/list.h" 13 #include "src/list.h"
14 #include "src/msan.h"
14 #include "src/snapshot/natives.h" 15 #include "src/snapshot/natives.h"
15 #include "src/snapshot/partial-serializer.h" 16 #include "src/snapshot/partial-serializer.h"
16 #include "src/snapshot/startup-serializer.h" 17 #include "src/snapshot/startup-serializer.h"
17 18
18 using namespace v8; 19 using namespace v8;
19 20
20 class SnapshotWriter { 21 class SnapshotWriter {
21 public: 22 public:
22 SnapshotWriter() : snapshot_cpp_path_(NULL), snapshot_blob_path_(NULL) {} 23 SnapshotWriter() : snapshot_cpp_path_(NULL), snapshot_blob_path_(NULL) {}
23 24
24 void SetSnapshotFile(const char* snapshot_cpp_file) { 25 void SetSnapshotFile(const char* snapshot_cpp_file) {
25 snapshot_cpp_path_ = snapshot_cpp_file; 26 snapshot_cpp_path_ = snapshot_cpp_file;
26 } 27 }
27 28
28 void SetStartupBlobFile(const char* snapshot_blob_file) { 29 void SetStartupBlobFile(const char* snapshot_blob_file) {
29 snapshot_blob_path_ = snapshot_blob_file; 30 snapshot_blob_path_ = snapshot_blob_file;
30 } 31 }
31 32
32 void WriteSnapshot(v8::StartupData blob) const { 33 void WriteSnapshot(v8::StartupData blob) const {
33 // TODO(crbug/633159): if we crash before the files have been fully created, 34 // TODO(crbug/633159): if we crash before the files have been fully created,
34 // we end up with a corrupted snapshot file. The build step would succeed, 35 // we end up with a corrupted snapshot file. The build step would succeed,
35 // but the build target is unusable. Ideally we would write out temporary 36 // but the build target is unusable. Ideally we would write out temporary
36 // files and only move them to the final destination as last step. 37 // files and only move them to the final destination as last step.
38
39 // Tell MSan to ignore uninitialized padding in the blob.
40 MSAN_MEMORY_IS_INITIALIZED(blob.data, blob.raw_size);
41
37 i::Vector<const i::byte> blob_vector( 42 i::Vector<const i::byte> blob_vector(
38 reinterpret_cast<const i::byte*>(blob.data), blob.raw_size); 43 reinterpret_cast<const i::byte*>(blob.data), blob.raw_size);
39 MaybeWriteSnapshotFile(blob_vector); 44 MaybeWriteSnapshotFile(blob_vector);
40 MaybeWriteStartupBlob(blob_vector); 45 MaybeWriteStartupBlob(blob_vector);
41 } 46 }
42 47
43 private: 48 private:
44 void MaybeWriteStartupBlob(const i::Vector<const i::byte>& blob) const { 49 void MaybeWriteStartupBlob(const i::Vector<const i::byte>& blob) const {
45 if (!snapshot_blob_path_) return; 50 if (!snapshot_blob_path_) return;
46 51
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 CHECK(blob.data); 186 CHECK(blob.data);
182 writer.WriteSnapshot(blob); 187 writer.WriteSnapshot(blob);
183 delete[] blob.data; 188 delete[] blob.data;
184 } 189 }
185 190
186 V8::Dispose(); 191 V8::Dispose();
187 V8::ShutdownPlatform(); 192 V8::ShutdownPlatform();
188 delete platform; 193 delete platform;
189 return 0; 194 return 0;
190 } 195 }
OLDNEW
« 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