github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/integration_test/fuzzcases/testdata/733.wat (about)

     1  (module
     2    (func (export "out of bounds")
     3        i32.const 0x100
     4        ;; The constant offset is calculated as 0xfffffffb + 4 (load target) == 0xffffffff.
     5        ;; If it is loaded as sign-extended 64-bit int, then the runtime offset calculation results in 0x100 -1 = 255,
     6        ;; which is *not* ouf-of-bounds access. However, the offset should be 0x1000000ff > 65536.
     7        i32.load offset=0xfffffffb
     8        drop
     9    )
    10    (func (export "store higher offset")
    11      i32.const 32769
    12      memory.grow
    13      drop
    14      i32.const 0x100 ;; runtime offset
    15      i64.const 0xffffffffffffffff ;; store target value.
    16      ;; This stores at 0x80000100 which lies in the last page, and 0x80000100 is
    17      ;; larger than math.MaxInt32, therefore in amd64 the offset calculation becomes two instructions.
    18      i64.store offset=0x80000000
    19    )
    20    (memory 1 32770) ;; allows 65536*32770 = 0x80020000 bytes.
    21    (export "" (func 0))
    22  )