summaryrefslogtreecommitdiff
path: root/deno2
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-06-18 15:55:36 +0200
committerGitHub <noreply@github.com>2018-06-18 15:55:36 +0200
commit064d889af05365b3d2051f0db800adc1ad977f3a (patch)
tree4e9cfb2cc9630fd32fb16dc4de4554a93cfa4b1d /deno2
parente6f51fd45820222cc2efea8478ad115b310e287a (diff)
Fix snapshot bug. (#267)
Diffstat (limited to 'deno2')
-rw-r--r--deno2/deno.cc4
-rw-r--r--deno2/js/mock_runtime.js8
-rw-r--r--deno2/mock_runtime_test.cc6
3 files changed, 17 insertions, 1 deletions
diff --git a/deno2/deno.cc b/deno2/deno.cc
index d21e0bcea..ec3665c93 100644
--- a/deno2/deno.cc
+++ b/deno2/deno.cc
@@ -250,8 +250,10 @@ v8::StartupData MakeSnapshot(v8::StartupData* prev_natives_blob,
SerializeInternalFields, nullptr));
}
+ // Note that using kKeep here will cause segfaults. This is demoed in the
+ // "SnapshotBug" test case.
auto snapshot_blob =
- creator->CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep);
+ creator->CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
return snapshot_blob;
}
diff --git a/deno2/js/mock_runtime.js b/deno2/js/mock_runtime.js
index f16161cf7..f845dae20 100644
--- a/deno2/js/mock_runtime.js
+++ b/deno2/js/mock_runtime.js
@@ -67,3 +67,11 @@ function DoubleSubFails() {
deno.sub((channel, msg) => assert(false));
deno.sub((channel, msg) => assert(false));
}
+
+
+// The following join has caused SnapshotBug to segfault when using kKeep.
+[].join("");
+
+function SnapshotBug() {
+ assert("1,2,3" === String([1, 2, 3]));
+}
diff --git a/deno2/mock_runtime_test.cc b/deno2/mock_runtime_test.cc
index 908e2a7e6..4abf61d4d 100644
--- a/deno2/mock_runtime_test.cc
+++ b/deno2/mock_runtime_test.cc
@@ -90,6 +90,12 @@ TEST(MockRuntimeTest, TypedArraySnapshots) {
deno_delete(d);
}
+TEST(MockRuntimeTest, SnapshotBug) {
+ Deno* d = deno_new(nullptr, nullptr);
+ EXPECT_TRUE(deno_execute(d, "a.js", "SnapshotBug()"));
+ deno_delete(d);
+}
+
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
deno_init();