title: Assertion failure at random with Boost.Regex 1.53 and gcc 4.8.1 on CentOS 6.4
body: <p>Here is the code I'm working with to test regular expressions:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/regex.hpp&gt;
  //#include &lt;regex&gt;
  #include &lt;functional&gt;
  #include &lt;string&gt;
  
  int main(int argc, char** argv)
  {
      auto isMatch = [](const std::string&amp; text, const std::string&amp; pattern)-&gt;bool
      {
          return boost::regex_search(text,
              boost::regex(pattern, boost::regex::icase | boost::regex::nosubs)
          );
      };
  
      std::cout &lt;&lt; std::boolalpha &lt;&lt; isMatch("Hello, world!",
          R"(((\%3D)|(=))[^\n]*((\%27)|(\')|(\-\-)|(\%3B)|(;)))") &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>The code compiles fine, but when I run it, <em>sometimes</em> I get an assertion failure on what I can safely assume is a null shared_ptr that isn't supposed to be null. It happens seemingly at random as demonstrated here:</p>
  
  <pre><code>[jacktrueborn@inpost regextest]$ ./regextest
  false
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  false
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  false
  [jacktrueborn@inpost regextest]$ ./regextest
  false
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  false
  [jacktrueborn@inpost regextest]$ ./regextest
  false
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  false
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  regextest: /usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference&lt;T&gt;::type boost::shared_ptr&lt;T&gt;::operator*() const [with T = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;; typename boost::detail::sp_dereference&lt;T&gt;::type = boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char&gt; &gt;&amp;]: Assertion `px != 0' failed.
  Aborted (core dumped)
  [jacktrueborn@inpost regextest]$ ./regextest
  false
  [jacktrueborn@inpost regextest]$
  </code></pre>
  
  <p>And this is how I installed boost:</p>
  
  <pre><code>./bootstrap.sh --prefix=/usr
  sudo ./b2 install
  </code></pre>
  
  <p>I know this has been a problem in the past with this library and I haven't been able to find a satisfactory work-around; I'm wondering if one has surfaced and I just haven't seen it. However, I'm not sure if I'm even having the same problem given the flaky nature of the error. <code>std::regex</code> simply throws <code>std::regex_error</code>s while running so I can't use that.</p>
  
  <p>(I'm aware that isMatch doesn't need to be a lambda or even a real function in this instance, but in my non-contrived code, there is a reason for doing it this way.)</p>