glsl/nir: fix gl_nir_cross_validate_outputs_to_inputs() memory leak

For instance, this issue is triggered with
vs-to-fs-overlap.shader_test -auto -fbo:
Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7fe64f58e9a7 in calloc (/usr/lib64/libasan.so.6+0xb19a7)
    #1 0x7fe642ca2839 in _mesa_symbol_table_ctor ../src/mesa/program/symbol_table.c:286
    #2 0x7fe642ff003d in gl_nir_cross_validate_outputs_to_inputs ../src/compiler/glsl/gl_nir_link_varyings.c:728
    #3 0x7fe642d7c7d8 in gl_nir_link_glsl ../src/compiler/glsl/gl_nir_linker.c:1357
    #4 0x7fe642be6931 in st_link_glsl_to_nir ../src/mesa/state_tracker/st_glsl_to_nir.cpp:562
    #5 0x7fe642be6931 in st_link_shader ../src/mesa/state_tracker/st_glsl_to_nir.cpp:944
    #6 0x7fe642acab55 in link_program ../src/mesa/main/shaderapi.c:1336
    #7 0x7fe642acab55 in link_program_error ../src/mesa/main/shaderapi.c:1447
    #8 0x7fe6424aa389 in _mesa_unmarshal_LinkProgram src/mapi/glapi/gen/marshal_generated2.c:1911
    #9 0x7fe641fd912b in glthread_unmarshal_batch ../src/mesa/main/glthread.c:139
    #10 0x7fe641f48d48 in util_queue_thread_func ../src/util/u_queue.c:309
    #11 0x7fe641fa442a in impl_thrd_routine ../src/c11/impl/threads_posix.c:67

Fixes: 7d1948e9b5 ("glsl: implement cross_validate_outputs_to_inputs() in nir linker")
Signed-off-by: Patrick Lerda <patrick9876@free.fr>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27071>
This commit is contained in:
Patrick Lerda 2024-01-12 02:18:35 +01:00 committed by Marge Bot
parent 0a68a94a51
commit bacace8634

View file

@ -745,7 +745,7 @@ gl_nir_cross_validate_outputs_to_inputs(const struct gl_constants *consts,
if (!validate_explicit_variable_location(consts,
output_explicit_locations,
var, prog, producer)) {
return;
goto out;
}
}
}
@ -799,7 +799,7 @@ gl_nir_cross_validate_outputs_to_inputs(const struct gl_constants *consts,
if (!validate_explicit_variable_location(consts,
input_explicit_locations,
input, prog, consumer)) {
return;
goto out;
}
while (idx < slot_limit) {
@ -807,7 +807,7 @@ gl_nir_cross_validate_outputs_to_inputs(const struct gl_constants *consts,
linker_error(prog,
"Invalid location %u in %s shader\n", idx,
_mesa_shader_stage_to_string(consumer->Stage));
return;
goto out;
}
output = output_explicit_locations[idx][input->data.location_frac].var;
@ -870,6 +870,7 @@ gl_nir_cross_validate_outputs_to_inputs(const struct gl_constants *consts,
}
}
out:
_mesa_symbol_table_dtor(table);
}