compiler: allow memory access after table.grow (#721)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
@@ -3417,7 +3417,6 @@ func (c *amd64Compiler) compileMemoryGrow() error {
|
|||||||
// After the function call, we have to initialize the stack base pointer and memory reserved registers.
|
// After the function call, we have to initialize the stack base pointer and memory reserved registers.
|
||||||
c.compileReservedStackBasePointerInitialization()
|
c.compileReservedStackBasePointerInitialization()
|
||||||
c.compileReservedMemoryPointerInitialization()
|
c.compileReservedMemoryPointerInitialization()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4130,6 +4129,7 @@ func (c *amd64Compiler) compileTableGrow(o *wazeroir.OperationTableGrow) error {
|
|||||||
|
|
||||||
// After return, we re-initialize reserved registers just like preamble of functions.
|
// After return, we re-initialize reserved registers just like preamble of functions.
|
||||||
c.compileReservedStackBasePointerInitialization()
|
c.compileReservedStackBasePointerInitialization()
|
||||||
|
c.compileReservedMemoryPointerInitialization()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3870,6 +3870,7 @@ func (c *arm64Compiler) compileTableGrow(o *wazeroir.OperationTableGrow) error {
|
|||||||
|
|
||||||
// After return, we re-initialize reserved registers just like preamble of functions.
|
// After return, we re-initialize reserved registers just like preamble of functions.
|
||||||
c.compileReservedStackBasePointerRegisterInitialization()
|
c.compileReservedStackBasePointerRegisterInitialization()
|
||||||
|
c.compileReservedMemoryRegisterInitialization()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,6 +209,19 @@ func Test719(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test720(t *testing.T) {
|
||||||
|
run(t, func(t *testing.T, r wazero.Runtime) {
|
||||||
|
mod, err := r.InstantiateModuleFromBinary(ctx, getWasmBinary(t, 720))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
f := mod.ExportedFunction("access memory after table.grow")
|
||||||
|
require.NotNil(t, f)
|
||||||
|
res, err := f.Call(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, uint32(0xffffffff), uint32(res[0]))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func Test721(t *testing.T) {
|
func Test721(t *testing.T) {
|
||||||
run(t, func(t *testing.T, r wazero.Runtime) {
|
run(t, func(t *testing.T, r wazero.Runtime) {
|
||||||
mod, err := r.InstantiateModuleFromBinary(ctx, getWasmBinary(t, 721))
|
mod, err := r.InstantiateModuleFromBinary(ctx, getWasmBinary(t, 721))
|
||||||
|
|||||||
BIN
internal/integration_test/fuzzcases/testdata/720.wasm
vendored
Normal file
BIN
internal/integration_test/fuzzcases/testdata/720.wasm
vendored
Normal file
Binary file not shown.
17
internal/integration_test/fuzzcases/testdata/720.wat
vendored
Normal file
17
internal/integration_test/fuzzcases/testdata/720.wat
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
(module
|
||||||
|
(func (export "access memory after table.grow") (result i32)
|
||||||
|
ref.null extern
|
||||||
|
i32.const 10
|
||||||
|
table.grow 0
|
||||||
|
;; This should work without any problem,
|
||||||
|
;; and should return non-trivial i32 result.
|
||||||
|
i32.load offset=396028 align=1
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Table and memory are as-is produced by fuzzer.
|
||||||
|
(table 1 264 externref)
|
||||||
|
(memory 10 10)
|
||||||
|
|
||||||
|
;; Setup the non trivial content on the i32.load
|
||||||
|
(data (i32.const 396028) "\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff")
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user