glsl: fix a race condition when inserting new types
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 12 May 2017 10:37:00 +0000 (12:37 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 13 Jun 2017 07:35:10 +0000 (09:35 +0200)
commitd6ec0aa7edfbe1c86861a4643b6b095a243d24ad
tree2ba473fec3931c7d4e96cae8b25ea2ce4e23e1fa
parent2e28e8b199abab76fa9509d3247b44a2cb31921d
glsl: fix a race condition when inserting new types

By splitting glsl_type::mutex into two, we can avoid dropping the hash
mutex while creating the new type instance (e.g. struct/record,
interface).

This fixes a time-of-check/time-of-use race where two threads would
simultaneously attempt to create the same type but end up with different
instances of glsl_type.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl_types.cpp
src/compiler/glsl_types.h