You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[spec] Parsing and validation in a single pass seems to be discouraged #1170
The problematic test checks br_table "with inconsistent target count (2 declared, 1 given)". But the intention is quite distant from how binary parser works. I.e. it assumes the parser fails because there is not enough targets provided
0e02 00 (missing LEB128 encoded target)
but the parser will just consume the next byte being the end 0b.
0e02 00 0b
and will fail because of the missing final 0b later. Even the test error message suggests that.
The problem is that in the middle we have br_table with 2 targets: 00 and 0b, where 0b one is invalid. The module is considered invalid before we are able to realize it is malformed.
Solution
We can just drop the test.
Or to preserve more/less the current cause of being malformed we can add some workaround/hacks preventing the additionally consumed byte seen as invalid br_table target. The only idea I have to achieve that is to make 0b target valid by adding 10 more functions to the module.
The only idea I have to achieve that is to make 0b target valid by adding 10 more functions to the module.
Right, though you would need to add blocks, not functions. I think it should work, as long as you made the br_table target length long enough too, so it attempts to access outside of the code section.
Activity
rossberg commentedon Mar 31, 2020
No, every negative test should contain only one mistake. But it's easy to miss cases where that's not the case. Happy to accept fixes. :)
chfast commentedon Apr 16, 2020
Problem
The problematic test checks
br_table"with inconsistent target count (2 declared, 1 given)". But the intention is quite distant from how binary parser works. I.e. it assumes the parser fails because there is not enough targets providedbut the parser will just consume the next byte being the end
0b.and will fail because of the missing final
0blater. Even the test error message suggests that.The problem is that in the middle we have
br_tablewith 2 targets:00and0b, where0bone is invalid. The module is considered invalid before we are able to realize it is malformed.Solution
br_tabletarget. The only idea I have to achieve that is to make0btarget valid by adding 10 more functions to the module.binji commentedon Apr 16, 2020
Right, though you would need to add blocks, not functions. I think it should work, as long as you made the
br_tabletarget length long enough too, so it attempts to access outside of the code section.[test] Remove br_table binary test
[test] Remove br_table binary test (#1205)
[test] Remove br_table binary test (WebAssembly#1205)
[test] Remove br_table binary test (WebAssembly#1205)
[test] Correct tests for missing elements
[test] Correct tests for missing elements
[test] Correct tests for missing elements (#1251)
[test] Correct tests for missing elements (WebAssembly#1251)
Merge from upstream spec (#407)