[Lldb-commits] [lldb] [lldb][windows] Use GetEnvironmentVariableW instead of _wgetenv (PR #199015)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Thu May 21 06:33:05 PDT 2026


charles-zablit wrote:

> The usage matches [learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-getenvironmentvariablew](https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-getenvironmentvariablew) but I don't see anything on that page saying that it is thread safe. Whereas for _wgetenv it explicitly says it's not.
> 
> Is that just how Win32 docs work? Note the ones that are not thread safe, the rest are implicitly safe?
> 
> I see there is a SetEnvironmentVariable. Maybe it is safe as long as we aren't using that at the same time.
> 
> If either of those guesses is true, this LGTM.

I think I did not read the docs correctly when I wrote this. I got my source from the .net docs: https://learn.microsoft.com/en-us/dotnet/core/unmanaged-api/profiling/icorprofilerinfo11-getenvironmentvariable-method

The does do not guarantee that `GetEnvironmentVariable` is thread safe. Closing this.

https://github.com/llvm/llvm-project/pull/199015


More information about the lldb-commits mailing list