Skip to content

Commit 969b7ba

Browse files
CreativeCylon1ace
authored andcommitted
tu: Fix potential alloc of 0 size
We can end up calling vk_multialloc_alloc with 0 size when `attachment_count` is 0 and `clearValueCount` is 0. Addressed: ``` Direct leak of 1 byte(s) in 1 object(s) allocated from: #0 0x7faf033ee0 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 #1 0x7fada5cc10 in vk_default_alloc ../src/vulkan/util/vk_alloc.c:26 #2 0x7fac50b270 in vk_alloc ../src/vulkan/util/vk_alloc.h:48 #3 0x7fac555040 in vk_multialloc_alloc ../src/vulkan/util/vk_alloc.h:234 #4 0x7fac555040 in void tu_CmdBeginRenderPass2<(chip)7>(VkCommandBuffer_T*, VkRenderPassBeginInfo const*, VkSubpassBeginInfo const*) ../src/freedreno/vulkan/tu_cmd_buffer.cc:4634 #5 0x7fac900760 in vk_common_CmdBeginRenderPass ../src/vulkan/runtime/vk_render_pass.c:261 ``` seen in: dEQP-VK.robustness.robustness2.bind.notemplate.r32i.dontunroll.nonvolatile.uniform_texel_buffer.no_fmt_qual.len_252.samples_1.1d.frag Fixes: 4cfd021 ("turnip: Save the renderpass's clear values in the cmdbuf state.") Signed-off-by: Karmjit Mahil <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32057> (cherry picked from commit c923eff)
1 parent ed2af40 commit 969b7ba

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

.pick_status.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@
614614
"description": "tu: Fix potential alloc of 0 size",
615615
"nominated": true,
616616
"nomination_type": 1,
617-
"resolution": 0,
617+
"resolution": 1,
618618
"main_sha": null,
619619
"because_sha": "4cfd021e3f74fd75e7998cae5697a1ba598237d6",
620620
"notes": null

src/freedreno/vulkan/tu_cmd_buffer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4414,8 +4414,8 @@ tu_CmdBeginRenderPass2(VkCommandBuffer commandBuffer,
44144414
const struct tu_image_view *, pass->attachment_count);
44154415
vk_multialloc_add(&ma, &cmd->state.clear_values, VkClearValue,
44164416
pRenderPassBegin->clearValueCount);
4417-
if (!vk_multialloc_alloc(&ma, &cmd->vk.pool->alloc,
4418-
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)) {
4417+
if (ma.size && !vk_multialloc_alloc(&ma, &cmd->vk.pool->alloc,
4418+
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)) {
44194419
vk_command_buffer_set_error(&cmd->vk, VK_ERROR_OUT_OF_HOST_MEMORY);
44204420
return;
44214421
}

0 commit comments

Comments
 (0)