#5911 closed Bugs (wontfix)
Crash in Boost::regex when _GLIBCXX_DEBUG is defined
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | regex |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | regex match crash | Cc: |
Description
Regex matching experiences a crash when _GLIBCXX_DEBUG is defined.
The crash was confirmed on multiple platforms, including Ubuntu, Fedora, and openBSD.
Full compiler command: g++ -D_GLIBCXX_DEBUG -DDEBUG=1 -g3 -ggdb -O0 regex-test.cpp -o regex-test.exe -lboost_regex
$ cat regex-test.cpp #include <boost/regex.hpp>
int main(int, char) {
const boost::regex re("[a-zA-Z]*"); bool match = boost::regex_match("asdf",re);
return (int) !match;
}
$ ./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
Program received signal SIGSEGV, Segmentation fault. 0x01c6fc26 in gnu_debug::_Safe_iterator_base::_M_detach_single (
this=0x3c0000f9) at /usr/src/gnu/lib/libstdc++-v3/../../gcc/libstdc++-v3/src/debug.cc:242
242 _M_prior->_M_next = _M_next; (gdb) bt full #0 0x01c6fc26 in gnu_debug::_Safe_iterator_base::_M_detach_single (
this=0x3c0000f9) at /usr/src/gnu/lib/libstdc++-v3/../../gcc/libstdc++-v3/src/debug.cc:242
No locals. #1 0x01c710be in gnu_debug::_Safe_sequence_base::_M_detach_all (
this=0xcfbd3a60) at /usr/src/gnu/lib/libstdc++-v3/../../gcc/libstdc++-v3/src/debug.cc:118
iter = (gnu_debug::_Safe_iterator_base *) 0x65707974
#2 0x1c00807b in ~_Safe_sequence_base (this=0xcfbd3a60) at safe_base.h:185 No locals. #3 0x1c00808f in ~_Safe_sequence (this=0xcfbd3a60) at safe_sequence.h:103 No locals. #4 0x1c0080a9 in ~vector (this=0xcfbd3a54) at vector:101 No locals. #5 0x1c008194 in ~match_results (this=0xcfbd3a54) at match_results.hpp:103 No locals. #6 0x1c008655 in boost::regex_match<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > (str=0x3c0000f9 "asdf", e=@0xcfbd3ac4,
flags=boost::regex_constants::match_default) at regex_match.hpp:90
m = {
m_subs = {<std::__norm::vector<boost::sub_match<const char*>,std::allocator<boost::sub_match<const char*> > >> = {<std::__norm::_Vector_base<boost::sub_match<const char*>,std::allocator<boost::sub_match<const char*> > >> = {
_M_impl = {<std::allocator<boost::sub_match<const char*> >> = {<gnu_cxx::new_allocator<boost::sub_match<const char*> >> = {<No data fields>}, <No data fields>}, _M_start = 0x88c4f100, _M_finish = 0x88c4f124,
_M_end_of_storage = 0x88c4f124}}, <No data fields>}, <gnu_debug::_Safe_sequence<std::__debug::vector<boost::sub_match<const char*>, std::allocator<boost::sub_match<const char*> > > >> = {<gnu_debug::_Safe_sequence_base> = {
_M_iterators = 0x3c0000f9, _M_const_iterators = 0x0, _M_version = 1}, <No data fields>}, _M_guaranteed_capacity = 0},
m_base = 0x85509400 "x\177�'", m_null = {<std::pair<const char*,const char*>> = {first = 0x3c0000fd "",
second = 0x3c0000fd ""}, matched = false}, m_named_subs = {px = 0x0,
pn = {pi_ = 0x0}}, m_last_closed_paren = 0, m_is_singular = false}
#7 0x1c005324 in main () at regex-test.cpp:8
re = {<boost::regbase> = {<No data fields>}, m_pimpl = {
px = 0x85509400, pn = {pi_ = 0x8ab55140}}}
match = 28
(gdb)
Attachments (1)
Change History (4)
by , 11 years ago
Attachment: | regex-test.cpp added |
---|
comment:1 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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.
HTH, John.
comment:3 by , 9 years ago
I think this can be fixed. We just need to check whether _GLIBCXX_DEBUG is defined. If defined, then undef it.
#ifdef _GLIBCXX_DEBUG #undef _GLIBCXX_DEBUG // CODE HERE #define _GLIBCXX_DEBUG #endif
Sample program to demonstrate crash