[regex] segfault from construction
::parse_extended (this=0xffde311c) at /usr/include/boost/regex/v4/basic_regex_parser.hpp:235 235 switch*this->m_traits.syntax_type(*m_position)) (gdb) print m_position $1 = 0x0 (gdb) bt #0 0x08066beb in boost::re_detail::basic_regex_parser
::parse_extended at /usr/include/boost/regex/v4/basic_regex_parser.hpp:235 #1 0xf7f9e364 in boost ::re_detail::basic_regex_parser >::parse () from /usr/lib/libboost_regex.so.2 #2 0xf7fa0eba in boost::basic_regex >::do_assign () from /usr/lib/
Hello all,
I've got what I suspect is a relatively unique problem that's
resulting in a segfault whenever I try to construct a boost::regex.
First some machine information:
Red Hat Enterprise Linux Server release 5.1 (Tikanga)
Linux 2.6.18-53.el5, SMP, x86_64
gcc 4.1.2 20070626 (Red Hat 4.1.2-14)
boost 1.33.1-10
Here's a small example that shows the problem:
#include
Andrew Troschinetz wrote:
Hello all,
I've got what I suspect is a relatively unique problem that's resulting in a segfault whenever I try to construct a boost::regex.
First some machine information: Red Hat Enterprise Linux Server release 5.1 (Tikanga) Linux 2.6.18-53.el5, SMP, x86_64 gcc 4.1.2 20070626 (Red Hat 4.1.2-14) boost 1.33.1-10
Hello!
I tested your example with the latest version of boost and also got
segfault.
krivenok@develop2 18:16:15 /tmp $ cat main.c
#include
Here's a small example that shows the problem: #include
#include <iostream> #include <string> using namespace std;
int main() { string input ("test test1 test2 test3"); string pattern ("\\btest\\b");
erase_regex (input, boost::regex (pattern));
cout << input << endl; // expecting " test1 test2 test3" return 0; }
Compile flags (and this is getting to the heart of the problem, I think): -g -m32 -malign-double -O3 -Wall -lboost_regex
Put all the above together in a bag, shake it up, and you get this segfault: 0x08066beb in boost::re_detail::basic_regex_parser
::parse_extended (this=0xffde311c) at /usr/include/boost/regex/v4/basic_regex_parser.hpp:235 235 switch*this->m_traits.syntax_type(*m_position)) (gdb) print m_position $1 = 0x0 (gdb) bt #0 0x08066beb in boost::re_detail::basic_regex_parser
::parse_extended at /usr/include/boost/regex/v4/basic_regex_parser.hpp:235 #1 0xf7f9e364 in boost ::re_detail::basic_regex_parser >::parse () from /usr/lib/libboost_regex.so.2 #2 0xf7fa0eba in boost::basic_regex >::do_assign () from /usr/lib/libboost_regex.so.2 #3 0x08050789 in main () at /usr/include/boost/regex/v4/basic_regex.hpp:254 So the immediate culprit is a dereferencing-null problem.
Interestingly, the problem goes away at -O, -O1, and -O2. Or -O3 but without -malign-double.
The same results.
I was wondering if this is a known problem, and if anyone else who's hand is forced to compile with -malign-double has seen this problem and been able to work around it?
-- Andrew Troschinetz Applied Research Laboratories
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Sincerely yours, Dmitry V. Krivenok Orange System Company Saint-Petersburg, Russia work phone: +7 812 332-32-40 cellular phone: +7 921 576-70-91 e-mail: krivenok@orangesystem.ru web: http://www.orangesystem.ru skype: krivenok_dmitry jabber: krivenok_dmitry@jabber.ru icq: 242-526-443
On Nov 25, 2008, at 9:22 AM, Dmitry V. Krivenok wrote:
I tested your example with the latest version of boost and also got segfault.
...
Just to confirm, this looks exactly like what I'm seeing on my end.
Just to note, I can actually recreate the error just by attempting a
simple:
#include
At 11:31 AM -0600 11/25/08, Andrew Troschinetz wrote:
On Nov 25, 2008, at 9:22 AM, Dmitry V. Krivenok wrote:
I tested your example with the latest version of boost and also got segfault.
...
Just to confirm, this looks exactly like what I'm seeing on my end. Just to note, I can actually recreate the error just by attempting a simple:
#include
int main() { boost::regex ("test"); return 0; } I hate to have to turn to regcomp/regexec, Boost.Regex is so nice :(
I would suggest that one/both of you open a trac ticket with configuration details and your sample programs so that John will have all the information he needs to find/fix it. Start here: http://svn.boost.org/ -- -- Marshall Marshall Clow Idio Software mailto:marshall@idio.com It is by caffeine alone I set my mind in motion. It is by the beans of Java that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning. It is by caffeine alone I set my mind in motion.
Marshall Clow wrote:
At 11:31 AM -0600 11/25/08, Andrew Troschinetz wrote:
On Nov 25, 2008, at 9:22 AM, Dmitry V. Krivenok wrote:
I tested your example with the latest version of boost and also got segfault.
...
Just to confirm, this looks exactly like what I'm seeing on my end. Just to note, I can actually recreate the error just by attempting a simple:
#include
int main() { boost::regex ("test"); return 0; } I hate to have to turn to regcomp/regexec, Boost.Regex is so nice :(
I would suggest that one/both of you open a trac ticket with configuration details and your sample programs so that John will have all the information he needs to find/fix it.
Indeed, and I will look into it, but... the compiler option in question *changes the ABI of the code produced by the compiler*... so why would you expect it *not* to segfault? The solution is to build Boost (and Boost.Regex in particular) with the same ABI-changing compiler options as your application. In short code compiled with -malign-double is not binary compatible with code compiled without it. HTH, John.
participants (4)
-
Andrew Troschinetz
-
Dmitry V. Krivenok
-
John Maddock
-
Marshall Clow