Eryk Sun <eryk...@gmail.com> added the comment:
The warning would not apply to Windows. The environment block is part of the Process Environment Block (PEB) record, which is protected by a critical-section lock. The runtime library acquires the PEB lock before accessing mutable PEB values. For example: Getting an environment variable: >>> win32api.GetEnvironmentVariable('foo') Breakpoint 0 hit ntdll!RtlQueryEnvironmentVariable: 00007ffc`d737a2f0 48895c2408 mov qword ptr [rsp+8],rbx ss:00000094`ec9ef470=0000000000000000 RtlQueryEnvironmentVariable acquires the PEB lock (i.e. ntdll!FastPebLock) before getting the value. The lock is passed to RtlEnterCriticalSection in register rcx: 0:000> be 2; g Breakpoint 2 hit ntdll!RtlEnterCriticalSection: 00007ffc`d737b400 4883ec28 sub rsp,28h 0:000> kc 3 Call Site ntdll!RtlEnterCriticalSection ntdll!RtlQueryEnvironmentVariable KERNELBASE!GetEnvironmentVariableW 0:000> ?? @rcx == (_RTL_CRITICAL_SECTION *)@@(ntdll!FastPebLock) bool true Setting an environment variable: >>> win32api.SetEnvironmentVariable('foo', 'eggs') Breakpoint 1 hit ntdll!RtlSetEnvironmentVar: 00007ffc`d73bc7d0 4c894c2420 mov qword ptr [rsp+20h],r9 ss:00000094`ec9ef488=0000000000000000 RtlSetEnvironmentVar acquires the PEB lock before setting the environment variable: 0:000> be 2; g Breakpoint 2 hit ntdll!RtlEnterCriticalSection: 00007ffc`d737b400 4883ec28 sub rsp,28h 0:000> kc 3 Call Site ntdll!RtlEnterCriticalSection ntdll!RtlSetEnvironmentVar KERNELBASE!SetEnvironmentVariableW 0:000> ?? @rcx == (_RTL_CRITICAL_SECTION *)@@(ntdll!FastPebLock) bool true ---------- nosy: +eryksun _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39375> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com