mohanson / pywasm

A WebAssembly interpreter written in pure Python
MIT License
450 stars 39 forks source link

raise exception when decoding unknown instruction #49

Closed zeldovich closed 2 years ago

zeldovich commented 2 years ago

When using pywasm to load a module containing instructions not supported by pywasm (such as memory.copy and memory.fill, encoded with the 0xfc byte prefix), the binary decoder assumes they are one byte long and proceeds decoding, leading to all kinds of confusion.

This change makes sure that all decoded instructions are explicitly listed in instruction.opcode, which prevents this kind of confusion at decode time.

mohanson commented 2 years ago

Yes, there is a mistake here.

In recent years, webassembly has added many new ISA, these unrecognized instructions can break the pywasm.