[Boost-bugs] [Boost C++ Libraries] #7211: path_locale destructor crashes when overloaded operator new and delete are present

Subject: [Boost-bugs] [Boost C++ Libraries] #7211: path_locale destructor crashes when overloaded operator new and delete are present
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-08-08 20:27:50


#7211: path_locale destructor crashes when overloaded operator new and delete are
present
------------------------------------------------------+---------------------
 Reporter: Michel Lemay <flaming_mike_@…> | Owner: bemandawes
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
  Version: Boost 1.51.0 | Severity: Problem
 Keywords: |
------------------------------------------------------+---------------------
 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:

 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

 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);

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7211>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC