zink: always add a per-prog ref for gpl libs

previously non-separable progs had their libs owned exclusively by
the shaders, which meant it was possible for a background compile job
to crash while the context was being destroyed when accessing libs
which no longer had active shaders

fixes #9234

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25088>
(cherry picked from commit fd297ecf98)
This commit is contained in:
Mike Blumenkrantz 2023-09-06 15:46:23 -04:00 committed by Dylan Baker
parent 47b531ce42
commit 6bc350389e
2 changed files with 4 additions and 2 deletions

View file

@ -5854,7 +5854,7 @@
"description": "zink: always add a per-prog ref for gpl libs",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -1121,6 +1121,8 @@ zink_create_gfx_program(struct zink_context *ctx,
if (screen->optimal_keys)
prog->libs = find_or_create_lib_cache(screen, prog);
if (prog->libs)
p_atomic_inc(&prog->libs->refcount);
struct mesa_sha1 sctx;
_mesa_sha1_init(&sctx);
@ -1545,7 +1547,7 @@ zink_destroy_gfx_program(struct zink_screen *screen,
blob_finish(&prog->blobs[i]);
}
}
if (prog->is_separable && prog->libs)
if (prog->libs)
zink_gfx_lib_cache_unref(screen, prog->libs);
ralloc_free(prog);