<div dir="ltr">Hi All,<br><div><br></div><div>I have a crash inside of rte_mempool_create which happens when I allocate multiple big mem pools(multiple GB each), in particular first argument of function alloc_seg(LINUX) is null, I investigated a little bit and it seems like there is a bug inside of rte_fbarray_find_next_n_free. </div><div><br></div><div>Inside of alloc_seg_walk rte_fbarray_find_next_n_free is used to find if the current memseg_arr has n (6 in my case) consecutive free pages, it does not in reality, but rte_fbarray_find_next_n_free returns that it does and we read out of bounds from memseg_arr which leads to null argument.</div><div><br></div><div>Bug is in find_next_n function called from rte_fbarray_find_next_n_free, <br></div><div> </div><div> first = MASK_LEN_TO_IDX(start);<br>   first_mod = MASK_LEN_TO_MOD(start);<br>   ignore_msk = ~((1ULL << first_mod) - 1); // in my case first_mod is 0 and ignore_mask is all 1<br></div><div><br></div><div> last = MASK_LEN_TO_IDX(arr->len);<br>  last_mod = MASK_LEN_TO_MOD(arr->len);<br>      last_msk = ~(UINT64_MAX << last_mod); //arr->len is 32 (arr is memseg_arr)<br></div><div><br></div><div>.....SKIP.....</div><div><br></div><div>             /* if we're looking for free spaces, invert the mask */<br>           if (!used) // THIS IS TRUE<br>                    cur_msk = ~cur_msk;<br><br>         /* combine current ignore mask with last index ignore mask */<br>         if (msk_idx == last) // TRUE<br>                  ignore_msk |= last_msk;  // BUG HERE</div><div>                                         // Since ignore_mask is all 1, it just absorbs last_msk and in the end, last_msk doesn't matter, which then leads to an incorrect result because bits after 32 are treated as free space and not masked correctly by last_msk. </div><div><br></div><div><br>                /* if we have an ignore mask, ignore once */<br>          if (ignore_msk) {<br>                     cur_msk &= ignore_msk;<br>                    ignore_msk = 0; // If there are multiple used_mask msk->n_masks this set to zero fixes the issue because when we get to BUG ignore_msk is already set to 0 and doesn't absosrb last_msk, but in my case, n_masks is 1.<br>               }<br></div><div><br></div><div>I think  ignore_msk |= last_msk;  should be replaced by cur_msk &= last_msk; I tried this and dpdk doesn't crash anymore and seems to work fine, but I'd like someone else familiar with this code to take a look at this. </div><div><br></div><div>Best Regards,</div><div>Oleksandr</div><div><br></div></div>