anv: assert that the target bo is valid when adding a reloc list
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 16 Sep 2020 16:38:58 +0000 (12:38 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 16 Sep 2020 19:58:16 +0000 (19:58 +0000)
this catches some undefined behavior like e.g., using a stale descriptorset
that references deleted bos, which I would absolutely never do

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6747>

src/intel/vulkan/anv_batch_chain.c

index c584f6f..e5d0e14 100644 (file)
@@ -200,6 +200,8 @@ anv_reloc_list_add(struct anv_reloc_list *list,
    if (result != VK_SUCCESS)
       return result;
 
+   assert(target_bo->gem_handle > 0 && target_bo->refcount > 0);
+
    /* XXX: Can we use I915_EXEC_HANDLE_LUT? */
    index = list->num_relocs++;
    list->reloc_bos[index] = target_bo;