Skip to content

classic-interp: array.fill false OOB with full length #4644

@XeniaLu

Description

@XeniaLu

On the classic interpreter, array.fill fails with "out of bounds" exception when length is identical to the array size, which is unexpected.

Test case

(type $i32_array (array (mut i32)))

(func $main
  (local $arr (ref $i32_array))

  ;; 创建一个大小为10的i32数组,初始值为0
  (array.new $i32_array
    (i32.const 0)    ;; 初始值
    (i32.const 10))  ;; 数组大小
  (local.set $arr)

  ;; 使用 array.fill 填充数组
  (array.fill $i32_array
    (local.get $arr)  ;; 数组引用
    (i32.const 0)     ;; 起始索引
    (i32.const 42)    ;; 填充值
    (i32.const 10))   ;; 填充长度 - 填满整个数组
)

Your environment

  • Host OS: Linux
  • WAMR main branch, x86-64, classic-interp

Expected behavior

No exception

Actual behavior

OOB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions