Sebastian Lackner sebastian@fds-team.de writes:
It looks like RtlRunOnceExecuteOnce is not safe to use (keyed_event not initialized yet). You could use pthread (like used before in init_teb_key), but probably moving to a function is sufficient to improve code readability. By avoiding the heavily indented code it would already look a bit less hacky. ;)
Simplifying the error handling would probably also help. For instance, pthread_setspecific() is not going to fail in any meaningful way.