Backed out changeset 80065f480a1f (bug 1737798) for causing TSAN exceptions. CLOSED TREE

This commit is contained in:
criss 2021-11-04 16:57:27 +02:00
Родитель 92efa9638d
Коммит 7cd579aaf3
7 изменённых файлов: 0 добавлений и 342 удалений

Просмотреть файл

@ -1,34 +0,0 @@
// |jit-test| allow-oom
function testIt(s, addr) {
try {
var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
(module
(memory (export "mem") i64 65537)
(data (i64.const ${addr}) "${s}"))`)));
} catch (e) {
if (e instanceof WebAssembly.RuntimeError && String(e).match(/too many memory pages/)) {
return;
}
throw e;
}
var mem = new Uint8Array(ins.exports.mem.buffer);
assertEq(String.fromCodePoint(...mem.slice(addr, addr + s.length)), s)
}
// Test that an active data segment targeting the area above 4GB works as expected
testIt("hello, world!", 0x100000020);
// Ditto, but crosses the 4GB boundary
var s = "supercalifragilisticexpialidocious";
testIt(s, 0x100000000 - Math.floor(s.length / 2));
// This is OOB above the 4GB boundary - throws OOB during instantiation.
// But can also throw for OOM when trying to create the memory.
assertErrorMessage(() => new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
(module
(memory (export "mem") i64 65537)
(data (i64.const ${65536*65537-10}) "supercalifragilisticexpialidocious"))`))),
WebAssembly.RuntimeError,
/(out of bounds)|(too many memory pages)/);

Просмотреть файл

@ -1,60 +0,0 @@
// |jit-test| allow-oom; slow;
// This is just like memory-copy.js, but it is marked slow because the
// C++-UB-safe operations we use for out-of-line copies on shared memory are slow
// and the >4GB copy takes a long time.
var HEAPMIN=65538;
var HEAPMAX=65540;
var PAGESIZE=65536;
try {
var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
(module
(memory (export "mem") i64 ${HEAPMIN} ${HEAPMAX} shared)
(func (export "f") (param $dst i64) (param $src i64) (param $n i64)
(memory.copy (local.get $dst) (local.get $src) (local.get $n))))`)));
} catch (e) {
if (e instanceof WebAssembly.RuntimeError && String(e).match(/too many memory pages/)) {
quit(0);
}
throw e;
}
var mem = new Uint8Array(ins.exports.mem.buffer);
var lowbase = 0xffff_1000;
var highbase = 0x1_0000_8000;
for ( let n=0; n < 256; n++ ) {
mem[n + lowbase] = n + 1;
mem[n + highbase] = n + 1;
}
// Copy from above 4GB to below
doit(0, highbase, 60);
// Copy from above 4GB with OOB to below
assertErrorMessage(() => ins.exports.f(0n, BigInt(HEAPMIN*PAGESIZE-32768), 65536n),
WebAssembly.RuntimeError,
/out of bounds/);
// Copy from below 4GB to above
doit(0x1_0000_0100, lowbase, 60);
// Copy from below 4GB to above with OOB
assertErrorMessage(() => ins.exports.f(BigInt(HEAPMIN*PAGESIZE-32768), BigInt(lowbase), 65536n),
WebAssembly.RuntimeError,
/out of bounds/);
// Copy across the 4GB boundary
doit(0xffff_ff80, lowbase, 256);
// Copy more than 4GB. Note overlap prevents full correctness checking.
ins.exports.f(BigInt(PAGESIZE), 0n, BigInt(PAGESIZE*(HEAPMIN-1)));
for ( let i=0 ; i < PAGESIZE; i++ )
assertEq(mem[i + PAGESIZE], mem[i]);
function doit(dst, src, n) {
ins.exports.f(BigInt(dst), BigInt(src), BigInt(n));
for ( let i=0 ; i < n; i++ )
assertEq(mem[dst + i], mem[src + i]);
}

Просмотреть файл

@ -1,58 +0,0 @@
// |jit-test| allow-oom
// Also see memory-copy-shared.js
var HEAPMIN=65538;
var HEAPMAX=65540;
var PAGESIZE=65536;
try {
var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
(module
(memory (export "mem") i64 ${HEAPMIN} ${HEAPMAX})
(func (export "f") (param $dst i64) (param $src i64) (param $n i64)
(memory.copy (local.get $dst) (local.get $src) (local.get $n))))`)));
} catch (e) {
if (e instanceof WebAssembly.RuntimeError && String(e).match(/too many memory pages/)) {
quit(0);
}
throw e;
}
var mem = new Uint8Array(ins.exports.mem.buffer);
var lowbase = 0xffff_1000;
var highbase = 0x1_0000_8000;
for ( let n=0; n < 256; n++ ) {
mem[n + lowbase] = n + 1;
mem[n + highbase] = n + 1;
}
// Copy from above 4GB to below
doit(0, highbase, 60);
// Copy from above 4GB with OOB to below
assertErrorMessage(() => ins.exports.f(0n, BigInt(HEAPMIN*PAGESIZE-32768), 65536n),
WebAssembly.RuntimeError,
/out of bounds/);
// Copy from below 4GB to above
doit(0x1_0000_0100, lowbase, 60);
// Copy from below 4GB to above with OOB
assertErrorMessage(() => ins.exports.f(BigInt(HEAPMIN*PAGESIZE-32768), BigInt(lowbase), 65536n),
WebAssembly.RuntimeError,
/out of bounds/);
// Copy across the 4GB boundary
doit(0xffff_ff80, lowbase, 256);
// Copy more than 4GB. Note overlap prevents full correctness checking.
ins.exports.f(BigInt(PAGESIZE), 0n, BigInt(PAGESIZE*(HEAPMIN-1)));
for ( let i=0 ; i < PAGESIZE; i++ )
assertEq(mem[i + PAGESIZE], mem[i]);
function doit(dst, src, n) {
ins.exports.f(BigInt(dst), BigInt(src), BigInt(n));
for ( let i=0 ; i < n; i++ )
assertEq(mem[dst + i], mem[src + i]);
}

Просмотреть файл

@ -1,58 +0,0 @@
// |jit-test| allow-oom; slow;
// This is just like memory-fill.js, but it is marked slow because the
// C++-UB-safe operations we use for out-of-line fills on shared memory are slow
// and the >4GB fill takes a long time.
try {
var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
(module
(memory (export "mem") i64 65537 65537 shared)
(func (export "f") (param $p i64) (param $c i32) (param $n i64)
(memory.fill (local.get $p) (local.get $c) (local.get $n))))`)));
} catch (e) {
if (e instanceof WebAssembly.RuntimeError && String(e).match(/too many memory pages/)) {
quit(0);
}
throw e;
}
var mem = new Uint8Array(ins.exports.mem.buffer);
// Fill above 4GB
doit(mem, 0x100000100, 37, 14);
// Fill OOB above 4GB
assertErrorMessage(() => ins.exports.f(0x10000FFFFn, 66, 14n),
WebAssembly.RuntimeError,
/out of bounds/);
assertEq(mem[0x10000FFFF], 0);
assertEq(mem[mem.length-1], 0);
// Fill across 4GB
doit(mem, 0x100000000 - 16, 42, 32);
// Fill more than 4GB...
ins.exports.f(0n, 86, 65536n*65537n);
assertEq(mem[mem.length-1], 86);
assertEq(mem[0], 86);
// Fill OOB more than 4GB
assertErrorMessage(() => ins.exports.f(1n, 75, 65536n*65537n),
WebAssembly.RuntimeError,
/out of bounds/);
assertEq(mem[1], 86);
assertEq(mem[mem.length-1], 86);
function doit(mem, addr, c, n) {
assertEq(mem[addr-1], 0);
assertEq(mem[addr], 0);
assertEq(mem[addr + n - 1], 0);
assertEq(mem[addr + n], 0);
ins.exports.f(BigInt(addr), c, BigInt(n));
assertEq(mem[addr-1], 0);
assertEq(mem[addr], c);
assertEq(mem[addr + n - 1], c);
assertEq(mem[addr + n], 0);
}

Просмотреть файл

@ -1,56 +0,0 @@
// |jit-test| allow-oom
// Also see memory-fill-shared.js
try {
var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
(module
(memory (export "mem") i64 65537)
(func (export "f") (param $p i64) (param $c i32) (param $n i64)
(memory.fill (local.get $p) (local.get $c) (local.get $n))))`)));
} catch (e) {
if (e instanceof WebAssembly.RuntimeError && String(e).match(/too many memory pages/)) {
quit(0);
}
throw e;
}
var mem = new Uint8Array(ins.exports.mem.buffer);
// Fill above 4GB
doit(mem, 0x100000100, 37, 14);
// Fill OOB above 4GB
assertErrorMessage(() => ins.exports.f(0x10000FFFFn, 66, 14n),
WebAssembly.RuntimeError,
/out of bounds/);
assertEq(mem[0x10000FFFF], 0);
assertEq(mem[mem.length-1], 0);
// Fill across 4GB
doit(mem, 0x100000000 - 16, 42, 32);
// Fill more than 4GB...
ins.exports.f(0n, 86, 65536n*65537n);
assertEq(mem[mem.length-1], 86);
assertEq(mem[0], 86);
// Fill OOB more than 4GB
assertErrorMessage(() => ins.exports.f(1n, 75, 65536n*65537n),
WebAssembly.RuntimeError,
/out of bounds/);
assertEq(mem[1], 86);
assertEq(mem[mem.length-1], 86);
function doit(mem, addr, c, n) {
assertEq(mem[addr-1], 0);
assertEq(mem[addr], 0);
assertEq(mem[addr + n - 1], 0);
assertEq(mem[addr + n], 0);
ins.exports.f(BigInt(addr), c, BigInt(n));
assertEq(mem[addr-1], 0);
assertEq(mem[addr], c);
assertEq(mem[addr + n - 1], c);
assertEq(mem[addr + n], 0);
}

Просмотреть файл

@ -1,31 +0,0 @@
// |jit-test| allow-oom
// This tests that we can grow the heap by more than 4GB. Other grow tests are
// in basic.js.
for (let shared of ['', 'shared']) {
try {
var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
(module
(memory (export "mem") i64 0 65540 ${shared})
(func (export "f") (param $delta i64) (result i64)
(memory.grow (local.get $delta))))`)));
} catch (e) {
if (e instanceof WebAssembly.RuntimeError && String(e).match(/too many memory pages/)) {
quit(0);
}
throw e;
}
let res = ins.exports.f(65537n);
if (res === -1n) {
quit(0); // OOM
}
assertEq(ins.exports.mem.buffer.byteLength, 65537*65536);
let mem = new Uint8Array(ins.exports.mem.buffer);
mem[65537*65536-1] = 37;
assertEq(mem[65537*65536-1], 37);
assertEq(ins.exports.f(4n), -1n);
}

Просмотреть файл

@ -1,45 +0,0 @@
// |jit-test| allow-oom
var S = (function () {
let s = "";
for ( let i=0; i < 16; i++ )
s += "0123456789abcdef"
return s;
})();
for (let shared of ['', 'shared']) {
try {
var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
(module
(memory (export "mem") i64 65537 65537 ${shared})
(data $d passive "${S}")
(func (export "f") (param $p i64) (param $o i32) (param $n i32)
(memory.init $d (local.get $p) (local.get $o) (local.get $n))))`)));
} catch (e) {
if (e instanceof WebAssembly.RuntimeError && String(e).match(/too many memory pages/)) {
quit(0);
}
throw e;
}
var mem = new Uint8Array(ins.exports.mem.buffer);
// Init above 4GB
doit(mem, 0x1_0000_1000, 1, S.length-1);
// Init above 4GB with OOM
assertErrorMessage(() => ins.exports.f(0x1_0000_ff80n, 0, 256),
WebAssembly.RuntimeError,
/out of bounds/);
// Init across 4GB
doit(mem, 0xffff_ff80, 3, 200);
}
function doit(mem, addr, offs, n) {
ins.exports.f(BigInt(addr), offs, n);
for (let i=0; i < n; i++) {
assertEq(mem[addr+i], S.charCodeAt(offs+i));
}
}