Commit 0afe5fc
authored
Handle more failures deallocating pooled memroy (#12888)
* Handle more failures deallocating pooled memroy
This commit replaces a few panics in the pooling allocator with
error-handling of what happens at runtime. This is a defense-in-depth
measure to ensure that the pooling allocator doesn't panic at runtime
and instead handles errors where possible.
The first path fixed is in `deallocate_memory` where resetting a slot
could result in an error being returned on non-Linux platforms, and if
this happened it would cause a panic. The error is instead gracefully
handled by continuing slot deallocation but avoiding putting the image
itself back into memory. This leaves the slot in an `Unknown` state
which is already handled by resetting the state upon reuse. The main
consequence here is that future statistics about resident bytes won't be
accurate, but these are already inaccurate on non-Linux platforms
anyway, so there's no loss.
The second path fixes is in flushing a `DecommitQueue` where
`decommit_pages` was asserted to succeed. Instead now the error is
handled by dropping all images and leaving slots in an `Unknown` state,
similar to `deallocate_memory`.
* Review comments1 parent 4b661a2 commit 0afe5fc
File tree
3 files changed
+79
-39
lines changed- crates/wasmtime/src/runtime/vm/instance/allocator
- pooling
3 files changed
+79
-39
lines changedLines changed: 42 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
721 | 721 | | |
722 | 722 | | |
723 | 723 | | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
728 | 728 | | |
729 | 729 | | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
744 | 742 | | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
749 | 769 | | |
750 | | - | |
751 | 770 | | |
752 | 771 | | |
753 | 772 | | |
| |||
Lines changed: 18 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
158 | | - | |
| 159 | + | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 163 | + | |
168 | 164 | | |
169 | 165 | | |
| 166 | + | |
170 | 167 | | |
171 | 168 | | |
172 | 169 | | |
| |||
175 | 172 | | |
176 | 173 | | |
177 | 174 | | |
178 | | - | |
| 175 | + | |
179 | 176 | | |
180 | 177 | | |
181 | 178 | | |
182 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
183 | 187 | | |
184 | 188 | | |
185 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
186 | 195 | | |
187 | 196 | | |
188 | 197 | | |
| |||
Lines changed: 19 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
459 | 463 | | |
460 | 464 | | |
461 | 465 | | |
462 | 466 | | |
463 | 467 | | |
464 | 468 | | |
465 | 469 | | |
466 | | - | |
| 470 | + | |
| 471 | + | |
467 | 472 | | |
468 | 473 | | |
469 | 474 | | |
470 | | - | |
| 475 | + | |
471 | 476 | | |
472 | 477 | | |
473 | 478 | | |
| |||
520 | 525 | | |
521 | 526 | | |
522 | 527 | | |
523 | | - | |
| 528 | + | |
524 | 529 | | |
525 | 530 | | |
526 | 531 | | |
| |||
587 | 592 | | |
588 | 593 | | |
589 | 594 | | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
590 | 598 | | |
591 | 599 | | |
592 | 600 | | |
593 | | - | |
| 601 | + | |
594 | 602 | | |
595 | | - | |
596 | | - | |
597 | 603 | | |
598 | 604 | | |
599 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
600 | 612 | | |
601 | 613 | | |
602 | 614 | | |
| |||
0 commit comments