Skip to content

Commit

Permalink
glsl/nir: fix gl_nir_cross_validate_outputs_to_inputs() memory leak
Browse files Browse the repository at this point in the history
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)
    android-rpi#1 0x7fe642ca2839 in _mesa_symbol_table_ctor ../src/mesa/program/symbol_table.c:286
    android-rpi#2 0x7fe642ff003d in gl_nir_cross_validate_outputs_to_inputs ../src/compiler/glsl/gl_nir_link_varyings.c:728
    android-rpi#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: 7d1948e ("glsl: implement cross_validate_outputs_to_inputs() in nir linker")
Signed-off-by: Patrick Lerda <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27071>
(cherry picked from commit bacace8634346f853547f51a0ea6ff8082a8dcb8)
  • Loading branch information
Patrick Lerda authored and 1ace committed Jan 16, 2024
1 parent 3cc0051 commit cd711b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pick_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"description": "glsl/nir: fix gl_nir_cross_validate_outputs_to_inputs() memory leak",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "7d1948e9b5d953cf8f5a56c676c935621b8da2bd",
"notes": null
Expand Down
7 changes: 4 additions & 3 deletions src/compiler/glsl/gl_nir_link_varyings.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,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;
}
}
}
Expand Down Expand Up @@ -800,15 +800,15 @@ 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) {
if (idx >= MAX_VARYING) {
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;
Expand Down Expand Up @@ -871,6 +871,7 @@ gl_nir_cross_validate_outputs_to_inputs(const struct gl_constants *consts,
}
}

out:
_mesa_symbol_table_dtor(table);
}

Expand Down

0 comments on commit cd711b4

Please sign in to comment.