Commit 541298f
authored
Fix a subtraction overflow in get_free_pages. (#1261)
The used pages can also be greater than the total pages for the same
reason as those in computing `get_available_pages`, and it can also
happen if the VM binding disabled GC, in which case we may over-allocate
without triggering GC. When it overflows, `get_free_pages` will cause
subtraction overflow, and will panic in debug build.
We switch to `saturating_sub` so that it will return 0 if overflow
happens. It still makes sense. 0 means there is no free pages because we
are over-allocating beyond the current heap size set by the GC trigger.1 parent 68bf1b6 commit 541298f
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
| |||
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
292 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
293 | 299 | | |
294 | 300 | | |
295 | 301 | | |
| |||
0 commit comments