Boost logo

Boost Testing :

Subject: [Boost-testing] [spirit] [test] Double deletion problem?
From: Alastair Rankine (arsptr_at_[hidden])
Date: 2009-09-14 17:37:00


Hi, I found an issue with testing my Spirit app, but after some
investigation it seems to be more of an issue with Boost Test.

The error message is as follows:

Running 2 test cases...

*** No errors detected
spirit2(53940) malloc: *** error for object 0x30001013006d0: pointer
being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

As the error message suggests I set a breakpoint and got this stack trace:

(gdb) bt
#0 0x00007fff88021b91 in malloc_error_break ()
#1 0x00007fff87f4b083 in free ()
#2 0x000000010006c3ac in boost::unit_test::framework_impl::clear
(this=0x1000deec0) at framework.ipp:133
#3 0x000000010006c4aa in
boost::unit_test::framework_impl::~framework_impl (this=0x1000deec0) at
framework.ipp:122
#4 0x000000010006da1e in __tcf_1 () at framework.ipp:225
#5 0x00007fff87f57274 in __cxa_finalize ()
#6 0x00007fff87f5718c in exit ()
#7 0x000000010000b7bb in start () at unit_test_parameters.ipp:172

Complete code is below. It is compiled on MacOS 10.6.1 with the default
gcc 4.2 compiler against boost 1.40 (installed via MacPorts).

I note that if the problem disappears when the two
BOOST_AUTO_TEST_SUITE lines are removed. Also it disappears when one of
the test cases is commented out.

Any help appreciated.

#define BOOST_TEST_MODULE spirit test
#include <boost/test/included/unit_test.hpp>

#include <boost/spirit/include/qi.hpp>

namespace qi = boost::spirit::qi;

template <typename Iterator>
struct MyGrammar : public qi::grammar<Iterator>
{
    MyGrammar()
        : MyGrammar::base_type(sp)
    {
        using boost::spirit::char_;

        sp = char_(' ');
    }

    qi::rule<Iterator> sp;
};

BOOST_AUTO_TEST_SUITE(SpiritTest)

BOOST_AUTO_TEST_CASE(Test1)
{
    MyGrammar<std::string::const_iterator> parser;
}

BOOST_AUTO_TEST_CASE(Test2)
{
    MyGrammar<std::string::const_iterator> parser;
}

BOOST_AUTO_TEST_SUITE_END()


Boost-testing list run by mbergal at meta-comm.com