[Boost-bugs] [Boost C++ Libraries] #13349: sregex not thread-safe when copied

Subject: [Boost-bugs] [Boost C++ Libraries] #13349: sregex not thread-safe when copied
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-12-18 15:44:34


#13349: sregex not thread-safe when copied
------------------------------+--------------------------
 Reporter: wave@… | Owner: Eric Niebler
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: xpressive
  Version: Boost 1.64.0 | Severity: Problem
 Keywords: |
------------------------------+--------------------------
 The following code does fail about every other execution:

 {{{
 #!c++

 #include <iostream>
 #include <boost/xpressive/xpressive.hpp>
 #include <boost/thread.hpp>
 using namespace std;
 using namespace boost::xpressive;

 struct MyRegexContainer {
     boost::xpressive::sregex myPatterns[20];

     MyRegexContainer() {

         myPatterns[0] = sregex::compile("[-]?[0-9]+\\.[0-9]{2}");
         for (int i =0; i < 20; i++)
         {
                 myPatterns[i] = myPatterns[0];
         }
         }

         void match(const std::string& wert, int index) const {
                         if(!regex_match(wert, myPatterns[index])){
                                 cout << "Index " << index << " did not
 match value " << wert << endl;
                         }
         }
 };

 namespace {
     void testSREGEXMultithreadedTASK() {
         static const MyRegexContainer a;
         for (int i = 0; i < 10000; ++i) {
                         a.match("33.00", i%20);
                         a.match("1.11", i%20);
         }
     }
 }

 int main() {
 #ifdef BOOST_DISABLE_THREADS
         cout << "BOOST_DISABLE_THREADS == TRUE" << wert << endl;
 #endif

 boost::thread_group tgroup;
     for (int i = 0; i < 100; ++i) {
         tgroup.create_thread(boost::bind(&testSREGEXMultithreadedTASK));
     }
     tgroup.join_all();

 return 0;
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13349>
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-12-18 15:51:58 UTC