Boost logo

Boost Users :

Subject: [Boost-users] SEGV in argv_traverser::handle_mismatch() on arg with leading space
From: Eric Prud'hommeaux (eric_at_[hidden])
Date: 2014-05-25 08:53:16


argv_traverser::handle_mismatch() appears to barf when parsing argv[1]
with leading (or only) spaces.

The examples boost/libs/test/example/external_main_example_1.cpp gets
a SEGV in include/boost/test/utils/runtime/cla/argv_traverser.ipp at
  m_remainder[m_remainder_size++] = p_separator

gdb says
p m_remainder_size
$1 = 116625

bt:
#0 0x000000000043f99b in boost::runtime::cla::argv_traverser::handle_mismatch (this=0x6dea00) at /home/eric/checkouts/libboost-1.55.inst/include/boost/test/utils/runtime/cla/argv_traverser.ipp:193
#1 0x000000000044059b in boost::runtime::cla::parser::parse (this=0x6dea00, argc=@0x7fffffffe164: 2, argv=0x7fffffffe3a8) at /home/eric/checkouts/libboost-1.55.inst/include/boost/test/utils/runtime/cla/parser.ipp:132
#2 0x00000000004265d5 in boost::unit_test::runtime_config::init (argc=@0x7fffffffe164: 2, argv=0x7fffffffe3a8) at /home/eric/checkouts/libboost-1.55.inst/include/boost/test/impl/unit_test_parameters.ipp:316
#3 0x000000000041630f in boost::unit_test::framework::init (init_func=0x4299b0 <init_unit_test_suite(int, char**)>, argc=2, argv=0x7fffffffe3a8) at /home/eric/checkouts/libboost-1.55.inst/include/boost/test/impl/framework.ipp:238
#4 0x0000000000423639 in boost::unit_test::unit_test_main (init_func=0x4299b0 <init_unit_test_suite(int, char**)>, argc=2, argv=0x7fffffffe3a8) at /home/eric/checkouts/libboost-1.55.inst/include/boost/test/impl/unit_test_main.ipp:177
#5 0x000000000042391c in main (argc=2, argv=0x7fffffffe3a8) at /home/eric/checkouts/libboost-1.55.inst/include/boost/test/impl/unit_test_main.ipp:237

$ LD_LIBRARY_PATH=../libboost-1.55.inst/lib/ ./external_main_example_1 ' '
Segmentation fault (core dumped)
$ LD_LIBRARY_PATH=../libboost-1.55.inst/lib/ ./external_main_example_1 ' a'
Segmentation fault (core dumped)
$ LD_LIBRARY_PATH=../libboost-1.55.inst/lib/ ./external_main_example_1 'a '
Running 3 test cases...
$ LD_LIBRARY_PATH=../libboost-1.55.inst/lib/ ./external_main_example_1 'a' ' '
Running 3 test cases...

I tried with test_case_template_example.cpp but got linker errors
consistent with a missing main. That example's include didn't include
the path segment "included/" so I thought it should compile with a
-DOOST_TEST_DYN_LINK -lboost_unit_test_framework . Anyways, the first
example should be enough to track down the bug.

-- 
-ericP
office: +1.617.599.3509
mobile: +33.6.80.80.35.59
(eric_at_[hidden])
Feel free to forward this message to any list for any purpose other than
email address distribution.
There are subtle nuances encoded in font variation and clever layout
which can only be seen by printing this message on high-clay paper.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net