Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setlocale stuck on Windows

setlocale(LC_ALL, "uk-UA") sometimes hangs/deadlocks for me with unknown reason. Call stack is:

ntdll.dll!_ZwWaitForSingleObject@12()   Unknown
ntdll.dll!_RtlpWaitOnCriticalSection@8()    Unknown
ntdll.dll!_RtlEnterCriticalSection@4()  Unknown
ntdll.dll!_LdrpLoadDll@28() Unknown
ntdll.dll!_LdrLoadDll@16()  Unknown
KernelBase.dll!_LoadLibraryExW@12() Unknown
ucrtbased.dll!__crt_findfile_traits::get_invalid_value(void)    Unknown
ucrtbased.dll!__acrt_lock_and_call<class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> >(enum __acrt_lock_id,class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> &&)    Unknown
ucrtbased.dll!__acrt_lock_and_call<class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> >(enum __acrt_lock_id,class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> &&)    Unknown
ucrtbased.dll!__acrt_lock_and_call<class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> >(enum __acrt_lock_id,class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> &&)    Unknown
ucrtbased.dll!__acrt_lock_and_call<class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> >(enum __acrt_lock_id,class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> &&)    Unknown
ucrtbased.dll!__acrt_lock_and_call<class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> >(enum __acrt_lock_id,class <lambda_a463b7b0560cfcaf9b17f27c6ef46564> &&)    Unknown
ucrtbased.dll!___acrt_can_use_vista_locale_apis()   Unknown
ucrtbased.dll!__expandlocale()  Unknown
ucrtbased.dll!__wsetlocale()    Unknown
ucrtbased.dll!__crt_call_and_cleanup<class <lambda_565169b3e3b494427ce1bebdd17b54ac>,class <lambda_f51fe5fd7c79a33db34fc9310f277369> >(class <lambda_565169b3e3b494427ce1bebdd17b54ac> &&,class <lambda_f51fe5fd7c79a33db34fc9310f277369> &&)   Unknown
ucrtbased.dll!__crt_seh_guarded_call<void>::operator()<class <lambda_0f92d0c5a8007722f95b3b6c71cd8e3e>,class <lambda_321f9d61c14d59ff00145e45db1313e0> &,class <lambda_3298c911d7b53f44106027a7fde9a80a> >(class <lambda_0f92d0c5a8007722f95b3b6c71cd8e3e> &&,class <lambda_321f9d61c14d59ff00145e45db1313e0> &,class <lambda_3298c911d7b53f44106027a7fde9a80a> &&) Unknown
ucrtbased.dll!__acrt_lock_and_call<class <lambda_321f9d61c14d59ff00145e45db1313e0> >(enum __acrt_lock_id,class <lambda_321f9d61c14d59ff00145e45db1313e0> &&)    Unknown
ucrtbased.dll!__crt_call_and_cleanup<class <lambda_565169b3e3b494427ce1bebdd17b54ac>,class <lambda_f51fe5fd7c79a33db34fc9310f277369> >(class <lambda_565169b3e3b494427ce1bebdd17b54ac> &&,class <lambda_f51fe5fd7c79a33db34fc9310f277369> &&)   Unknown
ucrtbased.dll!__crt_seh_guarded_call<void>::operator()<class <lambda_507d9fd6b66e39451a8852ba73f804a7>,class <lambda_565169b3e3b494427ce1bebdd17b54ac> &,class <lambda_f51fe5fd7c79a33db34fc9310f277369> &>(class <lambda_507d9fd6b66e39451a8852ba73f804a7> &&,class <lambda_565169b3e3b494427ce1bebdd17b54ac> &,class <lambda_f51fe5fd7c79a33db34fc9310f277369> &) Unknown
ucrtbased.dll!__crt_call_and_cleanup<class <lambda_565169b3e3b494427ce1bebdd17b54ac>,class <lambda_f51fe5fd7c79a33db34fc9310f277369> >(class <lambda_565169b3e3b494427ce1bebdd17b54ac> &&,class <lambda_f51fe5fd7c79a33db34fc9310f277369> &&)   Unknown
ucrtbased.dll!__wsetlocale()    Unknown
ucrtbased.dll!___acrt_update_multibyte_info()   Unknown
ucrtbased.dll!_setlocale()  Unknown

Sometimes it works but sometimes it never returns from it. I can not identify the reason. I use Visual Studio 2015 and Windows 7.

like image 772
V_V Avatar asked Feb 23 '16 08:02

V_V


1 Answers

This was a bug in the TH1 build (10.0.10240) of the Universal CRT. The bug was fixed in the Windows 10 November Update (TH2) build (10.0.10586).

You can download and install the updated Windows 10 SDK from https://dev.windows.com/en-us/downloads/windows-10-sdk. This SDK contains the static Universal CRT libraries, the debug Universal CRT DLLs (ucrtbased.dll et al.), and the retail Universal CRT DLLs for app-local redistribution.

You can download the updated Universal CRT redistributables from https://www.microsoft.com/en-us/download/details.aspx?id=50410. These contain the updated retail Universal CRT for central deployment in the system directory.

like image 66
James McNellis Avatar answered Sep 28 '22 11:09

James McNellis