-
Notifications
You must be signed in to change notification settings - Fork 27
Incompatibility with long LEB128 form from the core spec #153
Comments
The encoding of the table index in binary-leb128.wast is incorrect with the bulk-memory extensions, see #153. I saw and fixed the issue first in the reference types proposal (see WebAssembly/reference-types#95), but apparently it also exists here.
I saw and fixed this issue already in the reference-type proposal. I guess we should also apply the fix here. I created a PR for that. |
@gahaas Note that the test above (for data section) exhibits the same problem, as well as 2 more other tests which previously used long form of zero. |
Just looked up, bulk-memory-operations/test/core/binary.wast Lines 118 to 126 in 66d90a7
|
I doubt the long form is used anywhere (it would only happen if someone did it manually), so the backward compatibility risk seems relatively low. But you're right that it would be good to mention and remove tests. |
It could in theory also happen if an encoder used a 5-byte-padded LEB128 form to start with (like e.g. LLVM does at initial stage), but then didn't optimise it away in post-processing. |
Perhaps, though generally tools only do that for LEB128 values that represent a count/size that needs to be fixed-up. |
I assumed that index encoding shares same routines as count/size? |
Binaryen has different functions for fixed- and variable-length LEB128: https://github.com/WebAssembly/binaryen/blob/master/src/wasm-binary.h#L73-L104 Maybe LLVM does it differently? |
LLVM also can do it both ways: https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Support/LEB128.h It doesn't look like lld uses any padding when emitting the memory index: |
Thanks for checking! I guess if both Binaryen and LLVM don't do this, we should be on safe-ish side as that covers most toolchains.
Let's just do this then (test removal and explicit documentation). |
The encoding of the table index in binary-leb128.wast is incorrect with the bulk-memory extensions, see #153. I saw and fixed the issue first in the reference types proposal (see WebAssembly/reference-types#95), but apparently it also exists here.
I believe this was resolved. |
While implementing bulk memory proposal in my parser, I've noticed regressions in some core spec tests. In particular these two are very representative:
bulk-memory-operations/test/core/binary-leb128.wast
Lines 24 to 39 in 66d90a7
Here, a
0
table index (the only one allowed previously) is encoded in a suboptimal form of0x80 0x00
.The new layout used by this proposal relies on the table index previously being always zero and encoded as
0x00
, and assigns a different meaning to byte at the same position as0x80
and expects it to be one of the following values:Such long form is likely not something used by implementations in the wild, but it might be worth double-checking and either supporting such long form too, or at least making an explicit decision about this backward-incompatible binary representation change and removing (?) corresponding tests.
The text was updated successfully, but these errors were encountered: