Skip to content

Commit 18aa7fd

Browse files
addaleaxjoyeecheung
authored andcommitted
deps: V8: cherry-pick ea0719b8ed08
Original commit message: [snapshot] Do not defer ArrayBuffers during snapshotting ArrayBuffer instances are serialized by first re-assigning a index to the backing store field, then serializing the object, and then storing the actual backing store address again (and the same for the ArrayBufferExtension). If serialization of the object itself is deferred, the real backing store address is written into the snapshot, which cannot be processed when deserializing, leading to a crash. This fixes this by not deferring ArrayBuffer serialization and adding a DCHECK for the crash that previously occurred. Change-Id: Id9bea8268061bd0770cde7bfeb6695248978f994 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2144123 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#67114} Refs: v8/v8@ea0719b
1 parent a6a15fe commit 18aa7fd

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

deps/v8/src/snapshot/deserializer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class V8_EXPORT_PRIVATE Deserializer : public SerializerDeserializer {
107107
}
108108

109109
std::shared_ptr<BackingStore> backing_store(size_t i) {
110+
DCHECK_LT(i, backing_stores_.size());
110111
return backing_stores_[i];
111112
}
112113

deps/v8/src/snapshot/serializer-common.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,14 @@ void SerializerDeserializer::Iterate(Isolate* isolate, RootVisitor* visitor) {
126126
}
127127

128128
bool SerializerDeserializer::CanBeDeferred(HeapObject o) {
129-
return !o.IsString() && !o.IsScript() && !o.IsJSTypedArray();
129+
// ArrayBuffer instances are serialized by first re-assigning a index
130+
// to the backing store field, then serializing the object, and then
131+
// storing the actual backing store address again (and the same for the
132+
// ArrayBufferExtension). If serialization of the object itself is deferred,
133+
// the real backing store address is written into the snapshot, which cannot
134+
// be processed when deserializing.
135+
return !o.IsString() && !o.IsScript() && !o.IsJSTypedArray() &&
136+
!o.IsJSArrayBuffer();
130137
}
131138

132139
void SerializerDeserializer::RestoreExternalReferenceRedirectors(

0 commit comments

Comments
 (0)