Skip to content

Commit ea0719b

Browse files
addaleaxCommit Bot
authored andcommitted
[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 <[email protected]> Reviewed-by: Dan Elphick <[email protected]> Cr-Commit-Position: refs/heads/master@{#67114}
1 parent a6e8049 commit ea0719b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

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)