The instance object in the code below races on construction during multi-threaded use of the API when generating errors. The generated code on Windows/VS2013 is not thread safe. The actual error is generated in (http_client_winhttp.cpp) build_error_message while trying to access the object via windows_category(). I have not created a minimal reproduction scenario...
Simple fix, call the function somewhere safe (i.e. single threaded) to instantiate the object:
```c++
utility::details::windows_category();
```
```c++
const std::error_category & __cdecl windows_category()
{
static details::windows_category_impl instance;
return instance;
}
```
another:
```c++
const web::json::details::json_error_category_impl& web::json::details::json_error_category()
{
static web::json::details::json_error_category_impl instance;
return instance;
}
```
Comments: Hi bolts, Yes, you are absolutely right. VS 2013 didn't implement [concurrent initialize for local statics](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm). It is implemented in VS 2015. I'll put together a fix today. Thanks for this report and investigating. Steve
Simple fix, call the function somewhere safe (i.e. single threaded) to instantiate the object:
```c++
utility::details::windows_category();
```
```c++
const std::error_category & __cdecl windows_category()
{
static details::windows_category_impl instance;
return instance;
}
```
another:
```c++
const web::json::details::json_error_category_impl& web::json::details::json_error_category()
{
static web::json::details::json_error_category_impl instance;
return instance;
}
```
Comments: Hi bolts, Yes, you are absolutely right. VS 2013 didn't implement [concurrent initialize for local statics](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm). It is implemented in VS 2015. I'll put together a fix today. Thanks for this report and investigating. Steve