Possible race condition in hs_init_ghc?
In https://gitlab.haskell.org/ghc/ghc/-/blob/master/rts/RtsStartup.c#L243, the usage of hs_init_count is not atomic. According to the comment, second and subsequent inits are ignored, so concurrent inits should also be ignore in this regard, but calling hs_init_ghc in multiple threads risk racing here.
It's admittedly a rather exotic scenario that doesn't affect normal Haskell programs even if they use SMP, but it may affect the use case of embedding Haskell code in C and manually calling into Haskell from C. Should we make hs_init_count atomic to ensure hs_init_ghc is only invoked once even if it's called from multiple threads? cc @bgamari