Skip to content

Commit

Permalink
r300: fix constants_remap_table memory leak
Browse files Browse the repository at this point in the history
For instance, this issue is triggered with
"piglit/bin/object-namespace-pollution glBitmap program -auto -fbo":
Direct leak of 112 byte(s) in 7 object(s) allocated from:
    #0 0x7f472540e7ef in __interceptor_malloc (/usr/lib64/libasan.so.6+0xb17ef)
    #1 0x7f471a9ce18f in rc_remove_unused_constants ../src/gallium/drivers/r300/compiler/radeon_remove_constants.c:101
    #2 0x7f471a9b0836 in rc_run_compiler_passes ../src/gallium/drivers/r300/compiler/radeon_compiler.c:476
    #3 0x7f471a9b0ad5 in rc_run_compiler ../src/gallium/drivers/r300/compiler/radeon_compiler.c:498
    #4 0x7f471a9ec862 in r3xx_compile_fragment_program ../src/gallium/drivers/r300/compiler/r3xx_fragprog.c:172
    #5 0x7f471a9e1ab2 in r300_translate_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:516
    #6 0x7f471a9e6303 in r300_pick_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:591
    #7 0x7f471a9544fe in r300_create_fs_state ../src/gallium/drivers/r300/r300_state.c:1073
    #8 0x7f4718f2ebe5 in st_create_fp_variant ../src/mesa/state_tracker/st_program.c:1070
    #9 0x7f4718f374b5 in st_get_fp_variant ../src/mesa/state_tracker/st_program.c:1116
    #10 0x7f4718f38273 in st_precompile_shader_variant ../src/mesa/state_tracker/st_program.c:1281
    #11 0x7f4718f38273 in st_finalize_program ../src/mesa/state_tracker/st_program.c:1345
    #12 0x7f4718f389e9 in st_program_string_notify ../src/mesa/state_tracker/st_program.c:1378
    #13 0x7f47199d9f99 in set_program_string ../src/mesa/main/arbprogram.c:413

Fixes: 1c2c4dd ("r300g: copy the compiler from r300c")
Signed-off-by: Patrick Lerda <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27957>
(cherry picked from commit 29df857)
  • Loading branch information
Patrick Lerda authored and 1ace committed Mar 7, 2024
1 parent ebed52c commit cf7f7e7
Show file tree
Hide file tree
Showing 2 changed files with 3 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 @@ -1404,7 +1404,7 @@
"description": "r300: fix constants_remap_table memory leak",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "1c2c4ddbd1e97bfd13430521e5c09cb5ce8e36e6",
"notes": null
Expand Down
2 changes: 2 additions & 0 deletions src/gallium/drivers/r300/r300_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,8 @@ static void r300_delete_fs_state(struct pipe_context* pipe, void* shader)
struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader;
struct r300_fragment_shader_code *tmp, *ptr = fs->first;

free(fs->shader->code.constants_remap_table);

while (ptr) {
tmp = ptr;
ptr = ptr->next;
Expand Down

0 comments on commit cf7f7e7

Please sign in to comment.