if (getBuildConfiguration("debug") &&
(getBuildConfiguration("arm-simulator") || getBuildConfiguration("arm64-simulator") ||
getBuildConfiguration("mips32-simulator") || getBuildConfiguration("mips64-simulator")))
{ // Will timeout, so just quit early.
quit(0);
}
// Sundry test cases for the "partial write" bounds checking semantics.
const PAGESIZE = 65536;
// memory.fill: out of bounds, should not perform writes // // Arithmetic overflow of memory offset + len should not affect the behavior, we // should still fill up to the limit.
function mem_fill(min, max, shared, backup, write=backup*2) { if (shared == "shared" && !sharedMemoryEnabled()) return;
let ins = wasmEvalText(
`(module
(memory (export "mem") ${min} ${max} ${shared})
(func (export "run") (param $offs i32) (param $val i32) (param $len i32)
(memory.fill (local.get $offs) (local.get $val) (local.get $len))))`); // A fill past the end should throw *and* not have filled all the way up to // the end
let offs = min*PAGESIZE - backup;
let val = 37;
assertErrorMessage(() => ins.exports.run(offs, val, write),
WebAssembly.RuntimeError,
/index out of bounds/);
let v = new Uint8Array(ins.exports.mem.buffer); for (let i=0; i < backup; i++)
assertEq(v[offs+i], 0); for (let i=0; i < offs; i++)
assertEq(v[i], 0);
}
// memory.init: out of bounds of the memory or the segment, and should not perform // the operation at all. // // Arithmetic overflow of memoffset + len or of bufferoffset + len should not // affect the behavior.
// Note, the length of the data segment is 16. const mem_init_len = 16;
function mem_init(min, max, shared, backup, write) { if (shared == "shared" && !sharedMemoryEnabled()) return;
let ins = wasmEvalText(
`(module
(memory (export "mem") ${min} ${max} ${shared})
(data "\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42\\42")
(func (export "run") (param $offs i32) (param $len i32)
(memory.init 0 (local.get $offs) (i32.const 0) (local.get $len))))`); // A fill writing past the end of the memory should throw *and* not have filled // all the way up to the end. // // A fill reading past the end of the segment should throw *and* not have filled // memory with as much data as was available.
let offs = min*PAGESIZE - backup;
assertErrorMessage(() => ins.exports.run(offs, write),
WebAssembly.RuntimeError,
/index out of bounds/);
let v = new Uint8Array(ins.exports.mem.buffer); for (let i=0; i < min; i++)
assertEq(v[offs + i], 0);
}
// We exceed the bounds of the memory but not of the data segment
mem_init(1, 1, "", Math.floor(mem_init_len/2), mem_init_len);
mem_init(1, 1, "", Math.floor(mem_init_len/2)+1, mem_init_len);
mem_init(2, 4, "shared", Math.floor(mem_init_len/2), mem_init_len);
mem_init(2, 4, "shared", Math.floor(mem_init_len/2)+1, mem_init_len);
// We exceed the bounds of the data segment but not the memory
mem_init(1, 1, "", mem_init_len*4, mem_init_len*2-2);
mem_init(1, 1, "", mem_init_len*4-1, mem_init_len*2-1);
mem_init(2, 4, "shared", mem_init_len*4, mem_init_len*2-2);
mem_init(2, 4, "shared", mem_init_len*4-1, mem_init_len*2-1);
// We arithmetically overflow the memory limit but not the segment limit
mem_init(1, "", "", Math.floor(mem_init_len/2), 0xFFFFFF00);
// We arithmetically overflow the segment limit but not the memory limit
mem_init(1, "", "", PAGESIZE, 0xFFFFFFFC);
// memory.copy: out of bounds of the memory for the source or target, and should // not perform at all. Major cases: // // - non-overlapping regions // - overlapping regions with src >= dest // - overlapping regions with src == dest // - overlapping regions with src < dest // - arithmetic overflow on src addresses // - arithmetic overflow on target addresses // // for each of those, // // - src address oob // - target address oob // - both oob
// Arithmetic overflow on target adddress is an overlapping case.
mem_copy(1, 1, "", PAGESIZE-0x1000, PAGESIZE-20, 0xFFFFFF00);
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.26Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.