[Mesa-dev] [PATCH 1/2] st/mesa: fix crash in shader cache cased by race condition

Edward O'Callaghan funfunctor at folklore1984.net
Thu Feb 23 05:33:09 UTC 2017


1&2 are,
Reviewed-by: Edward O'Callaghan <funfunctor at folklore1984.net>

On 02/23/2017 02:59 PM, Timothy Arceri wrote:
> If a thread doesn't load GLSL IR from cache but does load TGSI
> from cache (that was created by another thread) than it will
> crash due to expecting gl_program_parameter_list to have been
> restored from the GLSL IR cache and not be null.
> ---
>  src/mesa/state_tracker/st_shader_cache.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c
> index 607e5b1..eb66f99 100644
> --- a/src/mesa/state_tracker/st_shader_cache.c
> +++ b/src/mesa/state_tracker/st_shader_cache.c
> @@ -233,6 +233,14 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
>        ralloc_free(buf);
>     }
>  
> +   /* Now that we have created the sha1 keys that will be used for writting to
> +    * the tgsi cache fallback to the regular glsl to tgsi path if we didn't
> +    * load the GLSL IR from cache. We do this as glsl to tgsi can alter things
> +    * such as gl_program_parameter_list which holds things like uniforms.
> +    */
> +   if (prog->data->LinkStatus != linking_skipped)
> +      return false;
> +
>     struct st_context *st = st_context(ctx);
>     for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
>        if (prog->_LinkedShaders[i] == NULL)
> @@ -389,12 +397,6 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
>  
>  fallback_recompile:
>  
> -   /* GLSL IR was compiled and linked so just fallback to the regular
> -    * glsl to tgsi path.
> -    */
> -   if (prog->data->LinkStatus != linking_skipped)
> -      return false;
> -
>     for (unsigned i = 0; i < prog->NumShaders; i++) {
>        _mesa_glsl_compile_shader(ctx, prog->Shaders[i], false, false, true);
>     }
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170223/5d543eaa/attachment-0001.sig>


More information about the mesa-dev mailing list