Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.4.2
-
None
-
Windows, Visual Studio 2022 build
Description
UniformBlockValueBuilder::buildActiveUniformNameValueMapStructHelper has a race condition that occasionally causes applications to crash.
The following lines seem to have a potential race.
const int fullBlockNameId = StringToInt::lookupId(fullBlockName); if (!rShaderData->hasPropertyValuesForBlock(fullBlockNameId)) rShaderData->generatePropertyValuesForBlock(fullBlockName); const ShaderData::PropertyValuesForBlock &propertiesForBlock = rShaderData->propertyValuesForBlock(fullBlockNameId);
It is possible for multiple threads to enter "generatePropertyValuesForBlock" on the same ShaderData object. This means one thread can have set the property values and have them returned from the call to "propertyValuesForBlock", but then while processing the returned value, the other thread will replace the ShaderData::PropertyValuesForBlock as it finishes its call to "generatePropertyValuesForBlock" leading to a crash. Either a mutex needs to be held throughout this function or the ShaderData::PropertyValuesForBlock needs to be returned by value instead of by reference so that when the other thread replaces it, it does not become invalid.