This was caused by DRW_select_buffer_elem_get not being failsafe. Handling the failure case properly fixes the issue.