Opened 10 years ago
Last modified 10 years ago
#7211 new Bugs
path_locale destructor crashes when overloaded operator new and delete are present
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.51.0 | Severity: | Problem |
Keywords: | Cc: |
Description
path_locale is defined using this construct in path.cpp:
std::locale path_locale(std::locale(), new windows_file_codecvt);
Under the debugger of VC10/11, the destructor of std::locale calls free() for this facet pointer when refcount reaches 0.
I ackknowledge this is a bug in dinkumware implementation of the microsoft STL. See for mor information:
That said, I suggest a workaround made using only standard calls.
in v3/src/windows_file_codecvt.hpp, change the constructor to pass along default refcount:
explicit windows_file_codecvt(size_t refs = 0)
: std::codecvt<wchar_t, char, std::mbstate_t>(refs) {}
and in v3/src/path.cpp, define path_locale like this:
windows_file_codecvt windows_cvt_path_locale(1);
std::locale path_locale(std::locale(), &windows_cvt_path_locale);
A quick grep in boost source code reveals other places using the same approach: