Re: [Boost-bugs] [Boost C++ Libraries] #6320: creation of path from std::string on Windows (VC10) crashes (access error)

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6320: creation of path from std::string on Windows (VC10) crashes (access error)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-12-27 16:05:15


#6320: creation of path from std::string on Windows (VC10) crashes (access error)
-----------------------------------+----------------------------------------
  Reporter: aris.basic@… | Owner: bemandawes
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: filesystem
   Version: Boost 1.48.0 | Severity: Showstopper
Resolution: | Keywords:
-----------------------------------+----------------------------------------

Comment (by wolfgang.fertsak@…):

 I think the problem is in file filesystem/v3/source/path.cpp in method

   const path::codecvt_type *& path::wchar_t_codecvt_facet()
   {
    static const std::codecvt<wchar_t, char, std::mbstate_t> *
      facet(
        &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
         (path_locale()));
    return facet;
   }

 This method is entered by multiple threads concurrently and the static
 pointer "facet" gets initialized by the first thread (which takes some
 time) but the other threads don't wait and just continue while facet is a
 NULL pointer.

 In boost 1.44 this crash didn't occur. It seems that the initialization of
 global variable
 const fs::path dot_path(L".");
 in filesystem/v3/source/path.cpp resulted in a call of
 path::wchar_t_codecvt_facet(), so the static "facet" pointer got
 initialized during program startup while no other threads were running.

 In boost 1.48 the initialization of the same globale variable doesn't
 result in a call of path::wchar_t_codecvt_facet() so race conditions might
 occur during initialization of the static "facet" pointer (in C++ 03).

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6320#comment:1>
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:08 UTC