Re: [Boost-bugs] [Boost C++ Libraries] #12987: boost::filesystem::exists crashes

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12987: boost::filesystem::exists crashes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-05-03 14:15:37


#12987: boost::filesystem::exists crashes
-------------------------------+------------------------
  Reporter: Leinad | Owner: bemandawes
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: filesystem
   Version: Boost 1.64.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+------------------------

Comment (by anonymous):

 Is it thread safe?
 {{{
 #include <boost\filesystem.hpp>

 const int thread_num = 10;
 boost::barrier barrier(thread_num + 1);

 bool c = []
 {
         std::vector<std::thread> threads;
         for (int i = 0; i < thread_num; ++i)
         {
                 threads.emplace_back([]
                 {
                         barrier.wait();
                         boost::filesystem::exists("c:");
                 });
         }
         barrier.wait();
         for (auto& thread: threads)
                 thread.join();
         return true;
 }();

 int main(int argc, char* argv[])
 {
         return 0;
 }
 }}}

 {{{c}}} could be (probably is) initialised before
 {{{compare_function_initializer}}} in the unnamed namespace in
 operations.cpp. All those threads will call {{{compare()}}} and there
 might be race condition at reading/setting {{{compare_function}}}.

 I guess on many platforms reading/assigning a pointer is atomic in
 practice, and {{{GetProcAddress}}} and {{{GetModuleHandle}}} are thread-
 safe, too, so this is not an issue here.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12987#comment:11>
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-05-03 14:20:12 UTC