Boost C++ Libraries: Ticket #5911: Crash in Boost::regex when _GLIBCXX_DEBUG is defined https://svn.boost.org/trac10/ticket/5911 <p> Regex matching experiences a crash when _GLIBCXX_DEBUG is defined. </p> <p> The crash was confirmed on multiple platforms, including Ubuntu, Fedora, and openBSD. </p> <p> Full compiler command: g++ -D_GLIBCXX_DEBUG -DDEBUG=1 -g3 -ggdb -O0 regex-test.cpp -o regex-test.exe -lboost_regex </p> <p> $ cat regex-test.cpp #include &lt;boost/regex.hpp&gt; </p> <p> int main(int, char<strong>) { </strong></p> <blockquote> <p> const boost::regex re("<sup>[a-zA-Z]*"); bool match = boost::regex_match("asdf",re); </sup></p> </blockquote> <blockquote> <p> return (int) !match; </p> </blockquote> <p> } </p> <p> $ ./regex-test.exe Segmentation fault (core dumped) $ gdb ./regex-test.exe GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-unknown-openbsd4.9"... (gdb) r Starting program: /home/jeffrey/Desktop/regex-test.exe </p> <p> Program received signal SIGSEGV, Segmentation fault. 0x01c6fc26 in <span class="underline">gnu_debug::_Safe_iterator_base::_M_detach_single ( </span></p> <blockquote> <p> this=0x3c0000f9) at /usr/src/gnu/lib/libstdc++-v3/../../gcc/libstdc++-v3/src/debug.cc:242 </p> </blockquote> <p> 242 _M_prior-&gt;_M_next = _M_next; (gdb) bt full <a class="missing ticket">#0</a> 0x01c6fc26 in <span class="underline">gnu_debug::_Safe_iterator_base::_M_detach_single ( </span></p> <blockquote> <p> this=0x3c0000f9) at /usr/src/gnu/lib/libstdc++-v3/../../gcc/libstdc++-v3/src/debug.cc:242 </p> </blockquote> <p> No locals. <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x01c710be in <span class="underline">gnu_debug::_Safe_sequence_base::_M_detach_all ( </span></p> <blockquote> <p> this=0xcfbd3a60) at /usr/src/gnu/lib/libstdc++-v3/../../gcc/libstdc++-v3/src/debug.cc:118 </p> <blockquote> <p> <span class="underline">iter = (</span>gnu_debug::_Safe_iterator_base *) 0x65707974 </p> </blockquote> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x1c00807b in ~_Safe_sequence_base (this=0xcfbd3a60) at safe_base.h:185 No locals. <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x1c00808f in ~_Safe_sequence (this=0xcfbd3a60) at safe_sequence.h:103 No locals. <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x1c0080a9 in ~vector (this=0xcfbd3a54) at vector:101 No locals. <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x1c008194 in ~match_results (this=0xcfbd3a54) at match_results.hpp:103 No locals. <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> 0x1c008655 in boost::regex_match&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; (str=0x3c0000f9 "asdf", e=@0xcfbd3ac4, </p> <blockquote> <p> flags=boost::regex_constants::match_default) at regex_match.hpp:90 </p> <blockquote> <p> m = { </p> </blockquote> </blockquote> <blockquote> <p> m_subs = {&lt;std::__norm::vector&lt;boost::sub_match&lt;const char*&gt;,std::allocator&lt;boost::sub_match&lt;const char*&gt; &gt; &gt;&gt; = {&lt;std::__norm::_Vector_base&lt;boost::sub_match&lt;const char*&gt;,std::allocator&lt;boost::sub_match&lt;const char*&gt; &gt; &gt;&gt; = { </p> <blockquote> <p> _M_impl = {&lt;std::allocator&lt;boost::sub_match&lt;const char*&gt; &gt;&gt; = {&lt;<span class="underline">gnu_cxx::new_allocator&lt;boost::sub_match&lt;const char*&gt; &gt;&gt; = {&lt;No data fields&gt;}, &lt;No data fields&gt;}, _M_start = 0x88c4f100, _M_finish = 0x88c4f124, </span></p> <blockquote> <p> _M_end_of_storage = 0x88c4f124}}, &lt;No data fields&gt;}, &lt;<span class="underline">gnu_debug::_Safe_sequence&lt;std::__debug::vector&lt;boost::sub_match&lt;const char*&gt;, std::allocator&lt;boost::sub_match&lt;const char*&gt; &gt; &gt; &gt;&gt; = {&lt;</span>gnu_debug::_Safe_sequence_base&gt; = { </p> </blockquote> <p> _M_iterators = 0x3c0000f9, _M_const_iterators = 0x0, _M_version = 1}, &lt;No data fields&gt;}, _M_guaranteed_capacity = 0}, </p> </blockquote> <p> m_base = 0x85509400 "x\177�'", m_null = {&lt;std::pair&lt;const char*,const char*&gt;&gt; = {first = 0x3c0000fd "", </p> <blockquote> <p> second = 0x3c0000fd ""}, matched = false}, m_named_subs = {px = 0x0, </p> </blockquote> <p> pn = {pi_ = 0x0}}, m_last_closed_paren = 0, m_is_singular = false} </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7" title="#7: Bugs: g++ 2.96 requires NO_STRINGSTREAM (closed: Fixed)">#7</a> 0x1c005324 in main () at regex-test.cpp:8 </p> <blockquote> <p> re = {&lt;boost::regbase&gt; = {&lt;No data fields&gt;}, m_pimpl = { </p> </blockquote> <blockquote> <p> px = 0x85509400, pn = {pi_ = 0x8ab55140}}} </p> <blockquote> <p> match = 28 </p> </blockquote> </blockquote> <p> (gdb) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5911 Trac 1.4.3 noloader@… Mon, 19 Sep 2011 00:58:13 GMT attachment set https://svn.boost.org/trac10/ticket/5911 https://svn.boost.org/trac10/ticket/5911 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">regex-test.cpp</span> </li> </ul> <p> Sample program to demonstrate crash </p> Ticket John Maddock Mon, 19 Sep 2011 08:13:56 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5911#comment:1 https://svn.boost.org/trac10/ticket/5911#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> The issue here is not Boost.Regex specific: defining _GLIBCXX_DEBUG changes the standard library ABI, so if you want to build your program with _GLIBCXX_DEBUG defined, then all C++ libraries including Boost.Regex must also be built with _GLIBCXX_DEBUG. </p> <p> HTH, John. </p> Ticket anonymous Mon, 19 Sep 2011 16:20:55 GMT <link>https://svn.boost.org/trac10/ticket/5911#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5911#comment:2</guid> <description> <p> Thanks John. </p> </description> <category>Ticket</category> </item> <item> <author>broken.zhou@…</author> <pubDate>Sun, 27 Oct 2013 07:08:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5911#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5911#comment:3</guid> <description> <p> I think this can be fixed. We just need to check whether _GLIBCXX_DEBUG is defined. If defined, then undef it. </p> <pre class="wiki">#ifdef _GLIBCXX_DEBUG #undef _GLIBCXX_DEBUG // CODE HERE #define _GLIBCXX_DEBUG #endif </pre> </description> <category>Ticket</category> </item> </channel> </rss>