Commit 80dc262
wasmparser: Fix validation of the
We need to additionally check that the callee's results are an exact match of
the caller's results. We were incorrectly allowing return calls that would push
more values on the operand stack than would be returned. That is fine with a
`call; return` sequence, where extra values on the stack are allowed to dangle,
but not okay with a `return_call`. With a `return_call` it doesn't make sense
because the callee might need a return pointer to put all its results into, but
the caller can't supply one since its frame is going away, nor can the caller
forward a return pointer that it received to the callee, since it might not
return enough values to require a return pointer. This commit fixes the
validation to match the spec and disallow `return_call`s that would leave
dangling values on the operand stack.
cc bytecodealliance/wasmtime#8704
Co-authored-by: Trevor Elliott <telliott@fastly.com>return_call family of instructions (#1585)1 parent 0d97aa7 commit 80dc262
File tree
3 files changed
+124
-10
lines changed- crates/wasmparser/src/validator
- tests
- local/function-references
- snapshots/local/function-references
3 files changed
+124
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
796 | 796 | | |
797 | 797 | | |
798 | 798 | | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
804 | 802 | | |
805 | 803 | | |
806 | 804 | | |
807 | 805 | | |
808 | | - | |
| 806 | + | |
809 | 807 | | |
810 | | - | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
811 | 815 | | |
812 | 816 | | |
813 | 817 | | |
| |||
864 | 868 | | |
865 | 869 | | |
866 | 870 | | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
867 | 914 | | |
868 | 915 | | |
869 | 916 | | |
| |||
1510 | 1557 | | |
1511 | 1558 | | |
1512 | 1559 | | |
| 1560 | + | |
1513 | 1561 | | |
1514 | 1562 | | |
1515 | 1563 | | |
| |||
1532 | 1580 | | |
1533 | 1581 | | |
1534 | 1582 | | |
1535 | | - | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
1536 | 1586 | | |
1537 | 1587 | | |
1538 | 1588 | | |
| |||
1549 | 1599 | | |
1550 | 1600 | | |
1551 | 1601 | | |
1552 | | - | |
1553 | | - | |
| 1602 | + | |
| 1603 | + | |
1554 | 1604 | | |
| 1605 | + | |
1555 | 1606 | | |
1556 | 1607 | | |
1557 | 1608 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
0 commit comments