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

Unified Diff: test/cctest/wasm/test-run-wasm-module.cc

Issue 2483053005: [wasm] Check data segments for zero-sized memory. (Closed)
Patch Set: Use a different formatter string Created 4 years, 1 month 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 | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm-module.cc
diff --git a/test/cctest/wasm/test-run-wasm-module.cc b/test/cctest/wasm/test-run-wasm-module.cc
index 190d0b003edc63f4bb59b12210fbb14ffde339c5..b96dbb9ceefd277264483af7e19012b343d33220 100644
--- a/test/cctest/wasm/test-run-wasm-module.cc
+++ b/test/cctest/wasm/test-run-wasm-module.cc
@@ -811,3 +811,106 @@ TEST(InitDataAtTheUpperLimit) {
}
Cleanup();
}
+
+TEST(EmptyMemoryNonEmptyDataSegment) {
+ {
+ Isolate* isolate = CcTest::InitIsolateOnce();
+ HandleScope scope(isolate);
+ testing::SetupIsolateForWasmModule(isolate);
+
+ ErrorThrower thrower(isolate, "Run_WasmModule_InitDataAtTheUpperLimit");
+
+ const byte data[] = {
+ WASM_MODULE_HEADER, // --
+ kMemorySectionCode, // --
+ U32V_1(4), // section size
+ ENTRY_COUNT(1), // --
+ kResizableMaximumFlag, // --
+ 0, // initial size
+ 0, // maximum size
+ kDataSectionCode, // --
+ U32V_1(7), // section size
+ ENTRY_COUNT(1), // --
+ 0, // linear memory index
+ WASM_I32V_1(8), // destination offset
+ kExprEnd,
+ U32V_1(1), // source size
+ 'c' // data bytes
+ };
+
+ testing::CompileInstantiateWasmModuleForTesting(isolate, &thrower, data,
+ data + arraysize(data),
+ ModuleOrigin::kWasmOrigin);
+ // It should not be possible to instantiate this module.
+ CHECK(thrower.error());
+ }
+ Cleanup();
+}
+
+TEST(EmptyMemoryEmptyDataSegment) {
+ {
+ Isolate* isolate = CcTest::InitIsolateOnce();
+ HandleScope scope(isolate);
+ testing::SetupIsolateForWasmModule(isolate);
+
+ ErrorThrower thrower(isolate, "Run_WasmModule_InitDataAtTheUpperLimit");
+
+ const byte data[] = {
+ WASM_MODULE_HEADER, // --
+ kMemorySectionCode, // --
+ U32V_1(4), // section size
+ ENTRY_COUNT(1), // --
+ kResizableMaximumFlag, // --
+ 0, // initial size
+ 0, // maximum size
+ kDataSectionCode, // --
+ U32V_1(6), // section size
+ ENTRY_COUNT(1), // --
+ 0, // linear memory index
+ WASM_I32V_1(24), // destination offset
+ kExprEnd,
+ U32V_1(0), // source size
+ };
+
+ testing::CompileInstantiateWasmModuleForTesting(isolate, &thrower, data,
+ data + arraysize(data),
+ ModuleOrigin::kWasmOrigin);
+ // It should be possible to instantiate this module.
+ CHECK(!thrower.error());
+ }
+ Cleanup();
+}
+
+TEST(MemoryWithOOBEmptyDataSegment) {
+ {
+ Isolate* isolate = CcTest::InitIsolateOnce();
+ HandleScope scope(isolate);
+ testing::SetupIsolateForWasmModule(isolate);
+
+ ErrorThrower thrower(isolate, "Run_WasmModule_InitDataAtTheUpperLimit");
+
+ const byte data[] = {
+ WASM_MODULE_HEADER, // --
+ kMemorySectionCode, // --
+ U32V_1(4), // section size
+ ENTRY_COUNT(1), // --
+ kResizableMaximumFlag, // --
+ 1, // initial size
+ 1, // maximum size
+ kDataSectionCode, // --
+ U32V_1(9), // section size
+ ENTRY_COUNT(1), // --
+ 0, // linear memory index
+ WASM_I32V_4(0x2468ace), // destination offset
+ kExprEnd,
+ U32V_1(0), // source size
+ };
+
+ testing::CompileInstantiateWasmModuleForTesting(isolate, &thrower, data,
+ data + arraysize(data),
+ ModuleOrigin::kWasmOrigin);
+ // It should be possible to instantiate this module.
+ CHECK(!thrower.error());
+ }
+ Cleanup();
+}
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698