mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-22 09:40:40 +02:00
mesa: fix potential race condition in with ATIShaders
The call looks up an ATIShader and creates it if it doesn't
already exist. However we weren't locking the hash between looking
up the name and adding it to the hash so it could be possible
another thread also generated the same name.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Fixes: 842c91300f ("mesa: enable GL name reuse by default for all drivers except virgl")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34091>
This commit is contained in:
parent
0e61d31e9d
commit
4c1e4d7b49
1 changed files with 5 additions and 3 deletions
|
|
@ -259,18 +259,20 @@ _mesa_BindFragmentShaderATI(GLuint id)
|
|||
newProg = ctx->Shared->DefaultFragmentShader;
|
||||
}
|
||||
else {
|
||||
_mesa_HashLockMutex(&ctx->Shared->ATIShaders);
|
||||
newProg = (struct ati_fragment_shader *)
|
||||
_mesa_HashLookup(&ctx->Shared->ATIShaders, id);
|
||||
_mesa_HashLookupLocked(&ctx->Shared->ATIShaders, id);
|
||||
if (!newProg || newProg == &DummyShader) {
|
||||
/* allocate a new program now */
|
||||
newProg = _mesa_new_ati_fragment_shader(ctx, id);
|
||||
if (!newProg) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFragmentShaderATI");
|
||||
_mesa_HashUnlockMutex(&ctx->Shared->ATIShaders);
|
||||
return;
|
||||
}
|
||||
_mesa_HashInsert(&ctx->Shared->ATIShaders, id, newProg);
|
||||
_mesa_HashInsertLocked(&ctx->Shared->ATIShaders, id, newProg);
|
||||
}
|
||||
|
||||
_mesa_HashUnlockMutex(&ctx->Shared->ATIShaders);
|
||||
}
|
||||
|
||||
/* do actual bind */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue