anv/allocator: Add a sanity assertion in state stream finish.
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 2 Oct 2015 23:24:42 +0000 (16:24 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 2 Oct 2015 23:24:42 +0000 (16:24 -0700)
We assert that the block offset we got while walking the list of blocks is
actually a multiple of the block size.  If something goes wrong and the GPU
decides to stomp on the surface state buffer we can end up getting
corruptions in our list of blocks.  This assertion makes such corruptions a
crash with a meaningful message rather than an infinite loop.

src/vulkan/anv_allocator.c

index 05126305b514bbdfeaeb0f24ab85b3af9f816d22..db04a2c236c67fe1ac985d2a7a147dd182f78af5 100644 (file)
@@ -697,6 +697,7 @@ anv_state_stream_finish(struct anv_state_stream *stream)
 
    block = stream->current_block;
    while (block != NULL_BLOCK) {
+      assert(block % stream->block_pool->block_size == 0);
       sb = stream->block_pool->map + block;
       next_block = VG_NOACCESS_READ(&sb->next);
       VG(VALGRIND_MEMPOOL_FREE(stream, VG_NOACCESS_READ(&sb->_vg_ptr)));