Skip to content

Commit

Permalink
test(xsnap): resource exhaustion is not catchable (x2)
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Mar 28, 2021
1 parent 3f5b9f0 commit 445d327
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/xsnap/test/test-xsnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,16 @@ test('heap exhaustion: orderly fail-stop', async t => {
test('property name space exhaustion: orderly fail-stop', async t => {
const grow = qty => `
const objmap = {};
for (let ix = 0; ix < ${qty}; ix += 1) {
const key = \`k\${ix}\`;
objmap[key] = 1;
if (!(key in objmap)) {
throw Error(key);
try {
for (let ix = 0; ix < ${qty}; ix += 1) {
const key = \`k\${ix}\`;
objmap[key] = 1;
if (!(key in objmap)) {
throw Error(key);
}
}
} catch (err) {
// name space exhaustion should not be catchable!
}
`;
for (const debug of [false, true]) {
Expand All @@ -435,10 +439,15 @@ test('parser buffer exhaustion: orderly fail-stop', async t => {
const grow = `
const send = it => issueCommand(ArrayBuffer.fromString(it));
let expr = '1+1';
for(;;) {
send(expr.length);
eval(expr);
expr = expr + ',' + expr;
try {
for(;;) {
send(expr.length);
eval(expr);
expr = expr + ',' + expr;
}
} catch (err) {
// buffer exhaustion should not be catchable!
send(err.message);
}
`;
for (const debug of [false, true]) {
Expand Down

0 comments on commit 445d327

Please sign in to comment.