I accidentally managed to reproduce an issue which has been plaguing
users for a while, where glslang throws an assert after closing a game
(and starting a new one).
pthread_setspecific was somehow failing with an EINVAL call, despite the
key never having been freed. I suspect some kind of corruption happening
when dynamic libraries are unloaded, but I doubt this is a bug in either
RetroArch or glslang per-se.
My workaround here is to tear down all TLS use in glslang after we're
done compiling. Somehow this works around the problem for me, and I
don't really see another viable fix. Valgrind does not say anything about the
issue, so doubt it's memory corruption either.
I had to fix a minor TLS leak in glslang as DetachProcess does not free
the PoolIndex TLS.