Fix missing negation in large_ralloc_no_move usize_min fallback

The second expansion attempt in large_ralloc_no_move omitted the !
before large_ralloc_no_move_expand(), inverting the return value.
On expansion failure, the function falsely reported success, making
callers believe the allocation was expanded in-place when it was not.
On expansion success, the function falsely reported failure, causing
callers to unnecessarily allocate, copy, and free.

Add unit test that verifies the return value matches actual size change.
This commit is contained in:
Slobodan Predolac 2026-03-27 09:57:28 -07:00
parent 87f9938de5
commit a0f2bdf91d
4 changed files with 81 additions and 1 deletions

View file

@ -147,7 +147,7 @@ large_ralloc_no_move(tsdn_t *tsdn, edata_t *edata, size_t usize_min,
}
/* Try again, this time with usize_min. */
if (usize_min < usize_max && usize_min > oldusize
&& large_ralloc_no_move_expand(
&& !large_ralloc_no_move_expand(
tsdn, edata, usize_min, zero)) {
arena_decay_tick(tsdn, arena_get_from_edata(edata));
return false;