Don't release global mutex before initialize/finalize is done
authorNiklas Haas <git@haasn.dev>
Mon, 8 Nov 2021 13:58:50 +0000 (14:58 +0100)
committerNiklas Haas <git@haasn.dev>
Mon, 8 Nov 2021 14:00:28 +0000 (15:00 +0100)
commit4302d51868daa94e81d3002073e9265397b2e444
tree1a5eef53e6e2c82465918873fb924b8d6e455b6e
parent3971424207e27a662d4416eedfb68e18ff287350
Don't release global mutex before initialize/finalize is done

Otherwise this can race with other threads for access to the fields it's
supposed to be initializing/finalizing.

For example, imagine another thread is calling ShInitialize() while the
first thread is calling ShFinalize() - the finalize function would
destroy the state at the same time as the initialize function is trying
to initialize it.

Holding on to the global lock for the entire function prevents all of
these failure modes.
glslang/MachineIndependent/ShaderLang.cpp