My working unpac repository

Don't clobber GetLastError in Win32 systhreads

See also PR 10220 and issue 8857.
SetLastError is called when accessing the TLS value This_thread.

(cherry picked from commit 93843575809433ea50e0406d56c0681287411f1b)

authored by

David Allsopp and committed by
Antonin Décimo
1280ec68 ba05db47

+9
+9
otherlibs/systhreads/st_stubs.c
··· 303 303 304 304 static void caml_thread_leave_blocking_section(void) 305 305 { 306 + #ifdef _WIN32 307 + /* TlsGetValue (called in This_thread) calls SetLastError which will mask any 308 + error which occurred prior to the caml_thread_leave_blocking_section call. 309 + EnterCriticalSection does not do this. */ 310 + DWORD error = GetLastError(); 311 + #endif 306 312 caml_thread_t th = This_thread; 307 313 /* Wait until the runtime is free */ 308 314 thread_lock_acquire(th->domain_id); ··· 310 316 corresponding to the thread currently executing and restore the 311 317 runtime state */ 312 318 restore_runtime_state(th); 319 + #ifdef _WIN32 320 + SetLastError(error); 321 + #endif 313 322 } 314 323 315 324 /* Create and setup a new thread info block.