On Wed Nov 22 14:34:50 2023 +0000, eric pouech wrote:
Out of curiosity, MSDN states that these functions are not thread safe (but without further details on ucrt vs msvcrt and various versions). Do you have evidence it's needed?
MSDN is wrong (except of getenv that is not thread-safe even with the locking). I have tested it with something similar to the attached patch. Note that the lock number doesn't match, it's internal so it should be ok. Probably our mtdll.h is outdated.
I have tested it in msvcrt and msvcr90. I have also tried modifying the environment from multiple threads and it didn't get corrupted (no entries were missing).
[test.diff](/uploads/a1bdd78cb1e652113c4c9208a1212cd1/test.diff)