Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/wasm/wasm-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3656,7 +3656,6 @@ static void validateMemories(Module& module, ValidationInfo& info) {

static void validateDataSegments(Module& module, ValidationInfo& info) {
for (auto& segment : module.dataSegments) {
auto size = segment->data.size();
if (segment->isPassive) {
info.shouldBeTrue(
module.features.hasBulkMemory(),
Expand Down Expand Up @@ -3693,14 +3692,6 @@ static void validateDataSegments(Module& module, ValidationInfo& info) {
segment->offset,
"memory segment offset should be constant");
FunctionValidator(module, &info).validate(segment->offset);
// If the memory is imported we don't actually know its initial size.
// Specifically wasm dll's import a zero sized memory which is perfectly
// valid.
if (!memory->imported()) {
info.shouldBeTrue(size <= memory->initial * Memory::kPageSize,
segment->data.size(),
"segment size should fit in memory (initial)");
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions test/lit/ctor-eval/flatten_too_big.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
;; The data segment here is at an offset too large to fit into the memory.
;; wasm-ctor-eval will flatten memory, and as a result the segment will start
;; at 0 and contain a great many 0's before that one 'a'. We should not report
;; a validation error or other problem due to that. (We also have nothing to
;; optimize here, so this test just checks we do not error.)

;; RUN: wasm-ctor-eval %s --ctors=test --kept-exports=test --quiet -all

(module
(memory $0 1 1)
(data (i32.const 123456) "a")

(export "test" (func $test))

(func $test
)
)