Commit f264511
authored
Don't preallocate based on bsatn length prefix (#5343)
# Description of Changes
Fixes an OOM kill in the proptest `bsatn_invalid_wont_decode`.
`bsatn_invalid_wont_decode` generates arbitrary invalid bytes, proves
validation fails, then still calls full AlgebraicValue::decode. For
generated array-like types, decode reads a u32 length prefix, and the
generic array visitor then reserves that capacity. But because they're
random bytes, this could cause a huge initial allocation which could OOM
kill the test process.
Now the visitor reserves a smaller initial capacity instead of assuming
the binary input data is well formed.
# API and ABI breaking changes
N/A
# Expected complexity level and risk
1
# Testing
This should fix the flaky `spacetimedb-sats` `Test Suite` failures that
occasionally end in a SIGKILL.1 parent a2ca083 commit f264511
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
774 | | - | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
775 | 780 | | |
776 | 781 | | |
777 | 782 | | |
| |||
0 commit comments