Skip to content

Commit 459e0d2

Browse files
authored
Remove incorrect validation of segment sizes (#6228)
This should be a runtime error, not a validator error. It caused a fuzzer failure on wasm-ctor-eval.
1 parent 3049fb8 commit 459e0d2

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

src/wasm/wasm-validator.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,7 +3656,6 @@ static void validateMemories(Module& module, ValidationInfo& info) {
36563656

36573657
static void validateDataSegments(Module& module, ValidationInfo& info) {
36583658
for (auto& segment : module.dataSegments) {
3659-
auto size = segment->data.size();
36603659
if (segment->isPassive) {
36613660
info.shouldBeTrue(
36623661
module.features.hasBulkMemory(),
@@ -3693,14 +3692,6 @@ static void validateDataSegments(Module& module, ValidationInfo& info) {
36933692
segment->offset,
36943693
"memory segment offset should be constant");
36953694
FunctionValidator(module, &info).validate(segment->offset);
3696-
// If the memory is imported we don't actually know its initial size.
3697-
// Specifically wasm dll's import a zero sized memory which is perfectly
3698-
// valid.
3699-
if (!memory->imported()) {
3700-
info.shouldBeTrue(size <= memory->initial * Memory::kPageSize,
3701-
segment->data.size(),
3702-
"segment size should fit in memory (initial)");
3703-
}
37043695
}
37053696
}
37063697
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
;; The data segment here is at an offset too large to fit into the memory.
2+
;; wasm-ctor-eval will flatten memory, and as a result the segment will start
3+
;; at 0 and contain a great many 0's before that one 'a'. We should not report
4+
;; a validation error or other problem due to that. (We also have nothing to
5+
;; optimize here, so this test just checks we do not error.)
6+
7+
;; RUN: wasm-ctor-eval %s --ctors=test --kept-exports=test --quiet -all
8+
9+
(module
10+
(memory $0 1 1)
11+
(data (i32.const 123456) "a")
12+
13+
(export "test" (func $test))
14+
15+
(func $test
16+
)
17+
)
18+

0 commit comments

Comments
 (0)