Skip to content

Commit

Permalink
tu: Fix memory leaks on VK_PIPELINE_COMPILE_REQUIRED
Browse files Browse the repository at this point in the history
For a TU_PIPELINE_GRAPHICS_LIB we were taking a ref to the descriptor
set layout but never releasing on VK_PIPELINE_COMPILE_REQUIRED.
Since VK_PIPELINE_COMPILE_REQUIRED is technically an error, the user
doesn't call vkDestroyPipeline() for it so the descriptor sets
referenced were never getting freed.

Addresses:
```
Direct leak of 304 byte(s) in 1 object(s) allocated from:
    #0 0x7fa5a93ee0 in __interceptor_malloc
       ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    waydroid#1 0x7fa44bac84 in vk_default_alloc ../src/vulkan/util/vk_alloc.c:26
    waydroid#2 0x7fa32ea5d8 in vk_alloc ../src/vulkan/util/vk_alloc.h:48
    waydroid#3 0x7fa32ea60c in vk_zalloc ../src/vulkan/util/vk_alloc.h:56
    waydroid#4 0x7fa32ea750 in vk_descriptor_set_layout_zalloc
       ../src/vulkan/runtime/vk_descriptor_set_layout.c:49
    waydroid#5 0x7fa306fc98 in tu_CreateDescriptorSetLayout(VkDevice_T*,
       VkDescriptorSetLayoutCreateInfo const*, VkAllocationCallbacks
const*, VkDescriptorSetLayout_T**)
../src/freedreno/vulkan/tu_descriptor_set.cc:161
```
and
```
Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f9b4b3ee0 in __interceptor_malloc
       ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    waydroid#1 0x7f9925e900 in ralloc_size ../src/util/ralloc.c:118
    waydroid#2 0x7f9925e8d4 in ralloc_context ../src/util/ralloc.c:105
    waydroid#3 0x7f98b4b214 in tu_pipeline_builder_build<(chip)7>
       ../src/freedreno/vulkan/tu_pipeline.cc:3898
    waydroid#4 0x7f98b46bd8 in tu_graphics_pipeline_create<(chip)7>
       ../src/freedreno/vulkan/tu_pipeline.cc:4203
    waydroid#5 0x7f98b22588 in VkResult
       tu_CreateGraphicsPipelines<(chip)7>(VkDevice_T*,
VkPipelineCache_T*, unsigned int, VkGraphicsPipelineCreateInfo const*,
VkAllocationCallbacks const*, VkPipeline_T**)
../src/freedreno/vulkan/tu_pipeline.cc:4234
```
seen in:
dEQP-VK.pipeline.pipeline_library.shader_module_identifier.pipeline_from_id.graphics.4_variants.no_spec_constants.no_pipeline_cache.all_zeros_id.no_exec_properties.vert_tesc_tese_frag

Cc: mesa-stable
Signed-off-by: Karmjit Mahil <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32188>
(cherry picked from commit 21baf2f6c1f829f7d09162d123fa726f52e800f1)
  • Loading branch information
CreativeCylon authored and dcbaker-intel committed Nov 21, 2024
1 parent 3ef5b47 commit 09a3504
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pick_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@
"description": "tu: Fix memory leaks on VK_PIPELINE_COMPILE_REQUIRED",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null
Expand Down
1 change: 1 addition & 0 deletions src/freedreno/vulkan/tu_pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3926,6 +3926,7 @@ tu_pipeline_builder_build(struct tu_pipeline_builder *builder,

result = tu_pipeline_builder_compile_shaders(builder, *pipeline);
if (result != VK_SUCCESS) {
tu_pipeline_finish(*pipeline, builder->device, builder->alloc);
vk_object_free(&builder->device->vk, builder->alloc, *pipeline);
return result;
}
Expand Down

0 comments on commit 09a3504

Please sign in to comment.