r300: fix memory leaks when register allocation fails
For instance, this issue is triggered with
"piglit/bin/ext_framebuffer_multisample-accuracy all_samples color depthstencil -auto -fbo":
Direct leak of 1160 byte(s) in 1 object(s) allocated from:
#0 0x7fbe8897d7ef in __interceptor_malloc (/usr/lib64/libasan.so.6+0xb17ef)
#1 0x7fbe7e7abfcc in rc_constants_copy ../src/gallium/drivers/r300/compiler/radeon_code.c:47
#2 0x7fbe7e7ec902 in r3xx_compile_fragment_program ../src/gallium/drivers/r300/compiler/r3xx_fragprog.c:174
#3 0x7fbe7e7e1b22 in r300_translate_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:516
#4 0x7fbe7e7e6373 in r300_pick_fragment_shader ../src/gallium/drivers/r300/r300_fs.c:591
#5 0x7fbe7e75456e in r300_create_fs_state ../src/gallium/drivers/r300/r300_state.c:1073
#6 0x7fbe7cd2ebe5 in st_create_fp_variant ../src/mesa/state_tracker/st_program.c:1070
#7 0x7fbe7cd374b5 in st_get_fp_variant ../src/mesa/state_tracker/st_program.c:1116
#8 0x7fbe7cd38273 in st_precompile_shader_variant ../src/mesa/state_tracker/st_program.c:1281
#9 0x7fbe7cd38273 in st_finalize_program ../src/mesa/state_tracker/st_program.c:1345
#10 0x7fbe7d798ca8 in st_link_glsl_to_nir ../src/mesa/state_tracker/st_glsl_to_nir.cpp:724
#11 0x7fbe7d798ca8 in st_link_shader ../src/mesa/state_tracker/st_glsl_to_nir.cpp:952
#12 0x7fbe7d6790d5 in link_program ../src/mesa/main/shaderapi.c:1336
#13 0x7fbe7d6790d5 in link_program_error ../src/mesa/main/shaderapi.c:1447
...
SUMMARY: AddressSanitizer: 2528456 byte(s) leaked in 1057 allocation(s).
Fixes: 54f6e72b27 ("r300: better register allocator for vertex shaders")
Signed-off-by: Patrick Lerda <patrick9876@free.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27792>
(cherry picked from commit 4d00edda00041de0492a5097353407f6d1781df3)
This commit is contained in:
parent
e94f1fc304
commit
d6aefb583e
4 changed files with 4 additions and 1 deletions
|
|
@ -1684,7 +1684,7 @@
|
|||
"description": "r300: fix memory leaks when register allocation fails",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "54f6e72b27154219be237690453bb9c3b57cd3ec",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -689,6 +689,7 @@ static void allocate_temporary_registers(struct radeon_compiler *c, void *user)
|
|||
|
||||
if (!ra_allocate(graph)) {
|
||||
rc_error(c, "Ran out of hardware temporaries\n");
|
||||
ralloc_free(graph);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -357,6 +357,7 @@ static void do_advanced_regalloc(struct regalloc_state * s)
|
|||
|
||||
if (!ra_allocate(graph)) {
|
||||
rc_error(s->C, "Ran out of hardware temporaries\n");
|
||||
ralloc_free(graph);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@ static void r300_translate_fragment_shader(
|
|||
abort();
|
||||
}
|
||||
|
||||
free(compiler.code->constants.Constants);
|
||||
rc_destroy(&compiler.Base);
|
||||
r300_dummy_fragment_shader(r300, shader);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue