iris: Reference the shader variant for last_vue_map as well

We call update_last_vue_map after updating the shaders, which compares
the new and old VUE maps.  Except...updating the shaders may have
dropped the last reference to the variant that ice->shaders.last_vue_map
belonged to, leading to a classic use-after-free.

Fix this by taking a reference to the variant for the last VUE stage,
so it stays around until we're done with it.

Fixes: 1afed51445 ("iris: Store a list of shader variants in the shader itself")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4311
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9143>
This commit is contained in:
Kenneth Graunke
2021-02-18 14:27:19 -08:00
committed by Marge Bot
parent 0fa7ec1473
commit 4c4a91abe5
4 changed files with 19 additions and 11 deletions
@@ -281,6 +281,7 @@ iris_destroy_program_cache(struct iris_context *ice)
for (int i = 0; i < MESA_SHADER_STAGES; i++) {
iris_shader_variant_reference(&ice->shaders.prog[i], NULL);
}
iris_shader_variant_reference(&ice->shaders.last_vue_shader, NULL);
hash_table_foreach(ice->shaders.cache, entry) {
struct iris_compiled_shader *shader = entry->data;