setlocale卡在Windows上

时间:2016-02-23 08:48:31

标签: c windows visual-studio winapi

setlocale(LC_ALL, "uk-UA")有时会因为未知原因而挂起/死锁。调用堆栈是:

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

有时它有效,但有时它永远不会从它返回。我无法确定原因。我使用Visual Studio 2015和Windows 7。

1 个答案:

答案 0 :(得分:14)

这是Universal CRT的TH1版本(10.0.10240)中的一个错误。该错误已在Windows 10 November Update(TH2)版本(10.0.10586)中修复。

您可以从https://dev.windows.com/en-us/downloads/windows-10-sdk下载并安装更新的Windows 10 SDK。此SDK包含静态通用CRT库,调试通用CRT DLL(ucrtbased.dll等),以及用于应用程序本地重新分发的零售通用CRT DLL。

您可以从https://www.microsoft.com/en-us/download/details.aspx?id=50410下载更新的通用CRT可再发行组件。它们包含更新的零售Universal CRT,用于在系统目录中进行集中部署。