Skip to content

MemoryPacking can result in dangling data.drops #2535

@aheejin

Description

@aheejin

After #2529, it was discovered that MemoryPacking pass does not properly delete or fix data.drop instructions (and possibly other instructions like memory.init) that refer to deleted segments. Given that #2426 is coming I'm not sure if it's worth fixing per se, but I'll file a bug report here to track this thing.

Test case:
Running
wasm-opt -all --memory-packing t.wast

t.wast:

(module
 (memory 1 1)
 (data (i32.const 0) "")
 (func $bar
  (drop
   (loop (result i32)
    (data.drop 0)
    (i32.const 42)
   )
  )
 )
)

results in a validation error saying [wasm-validator error in function bar] unexpected false: data.drop segment index out of bounds, on, ...

cc @tlively

Metadata

Metadata

Assignees

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