Skip to content

Commit

Permalink
ci: add test for OOB memory access
Browse files Browse the repository at this point in the history
This is not really a great way to discover the issue, but it's what
talvos is giving us for now. So let's at least make sure we have the
skeleton for further exploration later.
  • Loading branch information
sethp committed May 8, 2024
1 parent 19db9a7 commit e520523
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
44 changes: 23 additions & 21 deletions content/talvos/fill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ describe('fill', async () => {
})

test('runs', async () => {
let module = await getContents('talvos', 'fill.spvasm');
let tcf = await getContents('talvos', 'fill.tcf');
test_entry(
module,
await getContents('talvos', 'fill.spvasm'),
'FILL',
tcf,
await getContents('talvos', 'fill.tcf'),
)

expect(stderr).to.be.empty;
Expand All @@ -80,25 +78,29 @@ describe('fill', async () => {
`)
})

// test('exception', async () => {
// let instance = await talvos();
test('oob_write', async () => {
test_entry(
await getContents('talvos', 'fill.spvasm'),
'FILL',
`
BUFFER a 64 UNINIT
DESCRIPTOR_SET 0 0 0 a
// expect(() => instance.ccall('exception'))
// .toThrowErrorMatchingSnapshot();
// })
// test('assertion', async () => {
// let [stdout, stderr] = ['', ''];
// let instance = await talvos({
// print: (text: any) => { stdout += text; },
// printErr: (text: any) => { stderr += text; },
// });
DISPATCH 17 1 1
`
)

// expect(() => instance.cwrap('assertion')())
// .toThrowErrorMatchingSnapshot();
expect(stdout).to.be.empty;
expect(stderr).toMatchInlineSnapshot(`
"
Invalid store of 4 bytes to address 0x1000000000040 (Device scope)
Entry point: %1 FILL
Invocation: Global(16,0,0) Local(0,0,0) Group(16,0,0)
OpStore %18 %14
"
`);
})

// expect(stdout).toBe('');
// // TODO: this is sensitive to the line number of the assert
// expect(stderr).toMatchSnapshot();
// })

})
2 changes: 1 addition & 1 deletion wasm/talvos
Submodule talvos updated 1 files
+2 −2 lib/talvos/Memory.cpp
Binary file modified wasm/talvos-wasm.wasm
Binary file not shown.
Binary file modified wasm/talvos-wasm.wasm.dwp
Binary file not shown.

0 comments on commit e520523

Please sign in to comment.