roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
4.18k stars 297 forks source link

Improve leb128 tests for gen_wasm #7016

Closed lukewilliamboswell closed 1 month ago

lukewilliamboswell commented 1 month ago

I've encountered a bug when using gen_wasm and this is my attempt to investigate and hopefully improve the test cases at the same time.

$ wasm-validate app.wasm
001ca37: error: unable to read u32 leb128: function body size

I'm using an LLVM to brainstorm test cases, and then various different tools to work through these one by one, by hand to verify it has the expected behaviour.

I am currently highly suspicious of the implementation of overwrite_padded_u32, but I haven't spent a lot of time really understanding why yet.

I'm not sure if we would like to include more tests... this may be overkill.

lukewilliamboswell commented 1 month ago

Not planned