
I'm encountering a crash with Boost.Locale as the process terminates I initialise the global Boost.Locale in the contructor of a class with a single static instance (the ATL module to be exact) as I don't have access to the code of my main method (it comes from the Boost.Test runner). A static object seems to be the only logical place to put this code: #include <boost/locale.hpp> // boost::locale::generator class CModule : public ATL::CAtlModule { public : CModule() : ATL::CAtlModule() { try { // Initialise Boost.Locale translation mechanism generator gen; gen.add_messages_path("C:/My/Path"); gen.add_messages_domain("swish"); std::locale::global(gen("")); // default locale } catch (std::exception) {} } HRESULT AddCommonRGSReplacements(IRegistrarBase*) { return S_OK; } }; CModule _AtlModule; // Global module instance However, when I run my EXE, it crashes as it terminates with: Unhandled exception at 0x5ba43d93 (msvcp80d.dll) in test-shell_folder.exe: 0xC0000005: Access violation reading location 0x0321f4e4. and the following stack trace: msvcp80d.dll!std::_DebugHeapDelete<std::locale::facet>(std::locale::facet * _Ptr=0x023af590) msvcp80d.dll!_Deletegloballocale(void * ptr=0x5bb25258) msvcp80d.dll!tidy_global() msvcp80d.dll!_Init_atexit::~_Init_atexit() msvcp80d.dll!`dynamic atexit destructor for 'init_atexit''() msvcp80d.dll!_CRT_INIT(void * hDllHandle=0x5ba30000, unsigned long dwReason=0x00000000, void * lpreserved=0x00000001) msvcp80d.dll!__DllMainCRTStartup(void * hDllHandle=0x5ba30000, unsigned long dwReason=0x00000000, void * lpreserved=0x00000001) msvcp80d.dll!_DllMainCRTStartup(void * hDllHandle=0x5ba30000, unsigned long dwReason=0x00000000, void * lpreserved=0x00000001) ntdll.dll!_LdrpCallInitRoutine@16() ntdll.dll!_LdrShutdownProcess@0() ntdll.dll!_RtlExitUserProcess@4() kernel32.dll!76843b69() msvcr80d.dll!__crtExitProcess(int status=0x00000000) msvcr80d.dll!doexit(int code=0x00000000, int quick=0x00000000, int retcaller=0x00000000) msvcr80d.dll!exit(int code=0x00000000) test-shell_folder.exe!__tmainCRTStartup() test-shell_folder.exe!mainCRTStartup() If I move the initialisation code to run just before each point I need to use translate() then it works fine. So maybe this has something to do with the way static data is destroyed. This is on Windows - not sure about other platforms. Any ideas? Many thanks. Alex Lamaison P.S. I realise Boost.Locale isn't in Boost yet but previous discussions have been here so it seems a reasonable place to ask.