Boost C++ Libraries: Ticket #7211: path_locale destructor crashes when overloaded operator new and delete are present https://svn.boost.org/trac10/ticket/7211 <p> path_locale is defined using this construct in path.cpp: </p> <p> std::locale path_locale(std::locale(), new windows_file_codecvt); </p> <p> Under the debugger of VC10/11, the destructor of std::locale calls free() for this facet pointer when refcount reaches 0. </p> <p> I ackknowledge this is a bug in dinkumware implementation of the microsoft STL. See for mor information: </p> <p> <a class="ext-link" href="http://connect.microsoft.com/VisualStudio/feedback/details/750951/std-locale-implementation-in-crt-assumes-all-facets-to-be-allocated-on-crt-heap-and-crashes-in-destructor-in-debug-mode-if-a-facet-was-allocated-by-a-custom-allocator"><span class="icon">​</span>http://connect.microsoft.com/VisualStudio/feedback/details/750951/std-locale-implementation-in-crt-assumes-all-facets-to-be-allocated-on-crt-heap-and-crashes-in-destructor-in-debug-mode-if-a-facet-was-allocated-by-a-custom-allocator</a> </p> <p> That said, I suggest a workaround made using only standard calls. </p> <p> in v3/src/windows_file_codecvt.hpp, change the constructor to pass along default refcount: </p> <blockquote> <p> explicit windows_file_codecvt(size_t refs = 0) </p> <blockquote> <p> : std::codecvt&lt;wchar_t, char, std::mbstate_t&gt;(refs) {} </p> </blockquote> </blockquote> <p> and in v3/src/path.cpp, define path_locale like this: </p> <blockquote> <p> windows_file_codecvt windows_cvt_path_locale(1); </p> </blockquote> <blockquote> <p> std::locale path_locale(std::locale(), &amp;windows_cvt_path_locale); </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7211 Trac 1.4.3 Michel Lemay <flaming_mike_@…> Thu, 09 Aug 2012 15:02:57 GMT <link>https://svn.boost.org/trac10/ticket/7211#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7211#comment:1</guid> <description> <p> A quick grep in boost source code reveals other places using the same approach: </p> <ul><li>date-time have several uses of construct like this one: </li></ul><blockquote> <p> num_put* f = new num_put(); </p> </blockquote> <blockquote> <p> std::locale l = std::locale(a_ios.getloc(), f); </p> </blockquote> <ul><li>icu and locales: </li></ul><blockquote> <p> std::locale(in,new *_impl&lt;*&gt;(cd)); </p> </blockquote> <blockquote> <p> std::locale(tmp,new icu_formatters_cache(cd.locale)); </p> </blockquote> <blockquote> <p> ... </p> </blockquote> </description> <category>Ticket</category> </item> </channel> </rss>