freedreno: tex-miplevel-selection causes a creation of too many BOs without flushes, causing a crash
Piglit sub-tests of tex-miplevel-selection
(e.g. tex-miplevel-selection texture() 1d
) crash with cryptic cause:
malloc(): mismatching next->prev_size (unsorted)
Which is caused by uint16_t
wrap-around in grow()
function called from msm_submit_append_bo
static inline void
grow(void **ptr, uint16_t nr, uint16_t *max, uint16_t sz)
{
if ((nr + 1) > *max) {
if ((*max * 2) < (nr + 1))
*max = nr + 5;
else
*max = *max * 2;
*ptr = realloc(*ptr, *max * sz);
}
}
Here, even if nr
doesn't exceed uint16_t
, max
may exceed it when multiplied by 2
.
However, after changing the grow
to account this case, test crashed with:
error: fd_bo_map:364: mmap failed: Cannot allocate memory
It looks like we exceed some memory limit...
On the other hand forcing flushes makes the test pass.