[boost::locale::generator] Calling boost::locale::generator results in an exception in EnterCriticalSection
Hello, calling boost::locale::generator results in an exception in EnterCriticalSection. Does anybody have a hint to the cause of this problem? Every small clue is welcome. What could be a possible workaround? What is usually the reason for an exception in EnterCriticalSection? Code snippet: boost::locale::generator generator; generator.add_messages_path("..."); generator.add_messages_domain(".."); std::string lngCode = "en"; std::locale = generator(lngCode + ".WINDOWS-1252"); // this line crashes -> 0x0000005 EnterCriticalSection Boost Version: (boost_1_60_0) Visual Studio 2013 Some more hints: - it seems that there is a problem reading the translation file, which works fine in other applications. - there are no threads in the code - the problem is project dependent. Same code works in a different project. - the problem only appears if a specific header is included, but nothing in this header is ever executed before the crash. Removing the header/cpp removes the problem. - some C code is present in the code - the problem even appears when moving the snipped in main. Thanks for help.
On 24/05/2023 20:38, M L wrote:
std::locale = generator(lngCode + ".WINDOWS-1252"); // this line crashes
-> 0x0000005 EnterCriticalSection Boost Version: (boost_1_60_0) Visual Studio 2013
I'm assuming that's a typo and you meant 0xC000005, which is an access violation. Typically this means that something wasn't initialized properly. Boost 1.60 is ancient history; you should consider upgrading.
- the problem is project dependent. Same code works in a different project. - the problem only appears if a specific header is included, but nothing in this header is ever executed before the crash. Removing the header/cpp removes the problem. - some C code is present in the code - the problem even appears when moving the snipped in main.
Since you've narrowed the trigger down to a particular header, you can try narrowing it further by commenting in/out things in that header. Or post a full compilable MCVE if you want help. But the most likely problem is that you have an ODR violation -- some of your code is being compiled with different settings than others, which causes incompatible compiler output. The most common culprit for this sort of thing is incompatible #pragma pack or #define settings, but there are other possibilities. In particular you should not include external headers under the influence of a non-default pack setting (whether via #pragma or project/file settings) -- if you must use a different value then keep it to as narrow a scope as possible.
participants (2)
-
Gavin Lambert
-
M L