Skip to content

Commit

Permalink
nir: Fix no_lower_set leak on early return
Browse files Browse the repository at this point in the history
Addresses:
```
Indirect leak of 256 byte(s) in 2 object(s) allocated from:
    #0 0x7faaf53ee0 in __interceptor_malloc
       ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    waydroid#1 0x7fa8cfe900 in ralloc_size ../src/util/ralloc.c:118
    waydroid#2 0x7fa8cfeb20 in rzalloc_size ../src/util/ralloc.c:152
    waydroid#3 0x7fa8cff004 in rzalloc_array_size ../src/util/ralloc.c:232
    waydroid#4 0x7fa8d06a84 in _mesa_set_init ../src/util/set.c:133
    waydroid#5 0x7fa8d06bcc in _mesa_set_create ../src/util/set.c:152
    waydroid#6 0x7fa8d0939c in _mesa_pointer_set_create ../src/util/set.c:613
    waydroid#7 0x7fa95e5790 in nir_lower_mediump_vars
       ../src/compiler/nir/nir_lower_mediump.c:574
    waydroid#8 0x7fa862c1c8 in tu_spirv_to_nir(tu_device*, void*, unsigned long,
       VkPipelineShaderStageCreateInfo const*, tu_shader_key const*,
pipe_shader_type) ../src/freedreno/vulkan/tu_shader.cc:116
    waydroid#9 0x7fa8646f24 in tu_compile_shaders(tu_device*, unsigned long,
       VkPipelineShaderStageCreateInfo const**, nir_shader**,
tu_shader_key const*, tu_pipeline_layout*, unsigned char const*,
tu_shader**, char**, void*, nir_shader**, VkPipelineCreationFeedback*)
../src/freedreno/vulkan/tu_shader.cc:2741
    waydroid#10 0x7fa85a16a4 in tu_pipeline_builder_compile_shaders
	../src/freedreno/vulkan/tu_pipeline.cc:1887
    waydroid#11 0x7fa85eb844 in tu_pipeline_builder_build<(chip)7>
	../src/freedreno/vulkan/tu_pipeline.cc:3923
    #12 0x7fa85e6bd8 in tu_graphics_pipeline_create<(chip)7>
	../src/freedreno/vulkan/tu_pipeline.cc:4203
    #13 0x7fa85c2588 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.binding_model.mutable_descriptor.single.switches.uniform_texel_buffer_storage_image.update_write.no_source.no_source.pool_expand_types.pre_update.no_array.vert

Fixes: 7e986e5 ("nir/lower_mediump_vars: Don't lower mediump shared vars with atomic access.")
Signed-off-by: Karmjit Mahil <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32057>
(cherry picked from commit 2a7df331af65216e0229fe6481c1eca70221b225)
  • Loading branch information
CreativeCylon authored and 1ace committed Nov 13, 2024
1 parent 969b7ba commit 11843f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pick_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@
"description": "nir: Fix `no_lower_set` leak on early return",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "7e986e5f045a0e9da3ee64970a89d89907d0fcb4",
"notes": null
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/nir/nir_lower_mediump.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,10 @@ nir_lower_mediump_vars(nir_shader *shader, nir_variable_mode modes)
nir_variable *var = nir_deref_instr_get_variable(deref);

/* If we have atomic derefs that we can't track, then don't lower any mediump. */
if (!var)
if (!var) {
ralloc_free(no_lower_set);
return false;
}

_mesa_set_add(no_lower_set, var);
break;
Expand Down

0 comments on commit 11843f8

Please sign in to comment.