diff options
author | Thomas Lively <tlively@google.com> | 2022-11-03 10:10:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-03 10:10:01 -0700 |
commit | bf1782368dc6fee2d5fb9f4dd0cada2ca04ccb30 (patch) | |
tree | 34f685293dd0773bf43e832f95d88609bb3dcbdb /test | |
parent | daeac1e0735452d54c8b16b51cac88165d0d4eab (diff) | |
download | binaryen-bf1782368dc6fee2d5fb9f4dd0cada2ca04ccb30.tar.gz binaryen-bf1782368dc6fee2d5fb9f4dd0cada2ca04ccb30.tar.bz2 binaryen-bf1782368dc6fee2d5fb9f4dd0cada2ca04ccb30.zip |
Fix binary parsing of data segment memory (#5208)
The binary parser was eagerly getting the name of memories to set the `memory`
field of data segments, but that meant that when the memory names were updated
later while parsing the names section, the data segment memory fields would
become out of date. Update the issue by deferring setting the `memory` fields
like we do for other parts of IR that reference memories.
Also fix a segfault in the validator that was triggered by the reproducer for
this bug before the bug was fixed.
Fixes #5204.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/parse-named-memory.wast | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/lit/parse-named-memory.wast b/test/lit/parse-named-memory.wast new file mode 100644 index 000000000..3573376a6 --- /dev/null +++ b/test/lit/parse-named-memory.wast @@ -0,0 +1,14 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; Regression test for a binary parser bug in which memory names on data +;; segments were not properly updated to use memory names from the name section. + +;; RUN: wasm-as %s -g -o %t.wasm +;; RUN: wasm-opt %t.wasm -S -o - | filecheck %s + +(module + ;; CHECK: (memory $mem0 100) + (memory $mem0 100) + (data (offset (i32.const 0)) "") +) +;; CHECK: (data (i32.const 0) "") |