Skip to content

incorrect behavior in memory64 memory.init #4683

@kavoc-brown

Description

@kavoc-brown

Describe the bug

On the classic interpreter build with memory64 enabled, memory.init fails when asked to copy more than 4 GiB of data from a passive segment: instead of copying, it clears (zeroes) the destination region. The exported function observing the target buffer therefore reports 0 rather than the expected value derived from the copied data.

Per WAMR’s guidance, this affects a Tier-A feature (memory64) on the Tier-A classic interpreter.

Version

iwasm 2.4.3, x86_64, Ubuntu 22.04

To Reproduce

  1. Build WAMR classic interpreter with memory64.
cmake .. -DWAMR_BUILD_MEMORY64=1 -DWAMR_BUILD_FAST_INTERP=0
make
  1. Run the crafted module on WAMR. This module creates a passive segment > 4 GiB and performs memory.init of 65 537 bytes at address 0. memory64_init_bug.zip
iwasm -f memory64_init_bug.wasm
  1. See error: the interpreter prints 0x0:i32 (first byte of linear memory observed as zero).

Expected behavior

memory.init should copy 65 537 bytes of 0x41 into linear memory at address 0, so the exported function returns 65.

Actual Result

No bytes are copied; the target region is cleared. The exported function returns 0.

Additional context

Reference behavior on Wasmtime (returns 65, reflecting 0x41 bytes in the passive segment):

> wasmtime --version
wasmtime 33.0.0 (4ce8232ab 2025-05-20)
> wasmtime run -W memory64 --invoke=run memory64_init_bug.wasm
65

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions