Boost logo

Boost Users :

From: Stephen Torri (storri_at_[hidden])
Date: 2007-03-30 19:46:53


On Thu, 2007-03-29 at 20:40 +0300, Peter Dimov wrote:
> > #4 0x006c20ae in operator delete (p=0x8d9f2a8) at
> > sp_debug_hooks.cpp:201
>
> > #5 0x006d4983 in
> > __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned int
> > const, unsigned int> > >::deallocate ( this=0x8d8ae4c,
> > __p=0x8d9f2a8) at
> >
> > /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/ext/new_allocator.h:94
>
> This is an internal std::map deallocation so it should never fail in such a
> way. I think that it's quite possible that a write through a dangling
> pointer has corrupted your heap. You might want to switch to valgrind as the
> problem doesn't appear to be shared_ptr-related (your use seems OK) and
> valgrind does much more intensive and thorough checks.

I changed the XML parser I was using to remove a lot of the memory
problems I had. Now the issue still remains. Valgrind says that my
application does not leak anything. There are things that 4,767 bytes
are possibly lost and 2,600 bytes still reachable.

        (gdb) bt
        #0 0x47ceb178 in main_arena () from /lib/libc.so.6
        #1 0x6847ceb1 in ?? ()
        #2 0x48027e03 in std::operator<< <char, std::char_traits<char>, std::allocator<char> > () from /usr/lib/libstdc++.so.6
        #3 0x00b48806 in boost::io::detail::put_last<char, std::char_traits<char>, std::string> (os=@0xbfcd0fe4, x=@0xbfcd1454)
            at /usr/include/boost/format/feed_args.hpp:113
        #4 0x00b48932 in boost::io::detail::put<char, std::char_traits<char>, std::allocator<char>, std::string&> (x=@0xbfcd1454,
            specs=@0x8828e58, res=@0x8828e5c, buf=@0xbfcd135c, loc_p=0x0) at /usr/include/boost/format/feed_args.hpp:150
        #5 0x00b490d1 in boost::io::detail::distribute<char, std::char_traits<char>, std::allocator<char>, std::string&> (
            self=@0xbfcd1324, x=@0xbfcd1454) at /usr/include/boost/format/feed_args.hpp:241
        #6 0x00b49130 in boost::io::detail::feed<char, std::char_traits<char>, std::allocator<char>, std::string&> (
            self=@0xbfcd1324, x=@0xbfcd1454) at /usr/include/boost/format/feed_args.hpp:251
        #7 0x00b491f6 in boost::basic_format<char, std::char_traits<char>, std::allocator<char> >::operator%<std::string> (
            this=0xbfcd1324, x=@0xbfcd1454) at /usr/include/boost/format/format_class.hpp:68
        #8 0x00b44372 in libreverse::infrastructure::Configuration_Parser::parse_Data (this=0xbfcd1448)
            at Configuration_Parser.cpp:57
        #9 0x00b4a579 in libreverse::infrastructure::Configurator::Instance (file=@0xbfcd150c) at Configurator.cpp:39
        #10 0x00be82e3 in libreverse::infrastructure::Data_Source_Factory::Instance () at Data_Source_Factory.cpp:141
        #11 0x00b32d44 in Component (this=0x88287d0, id=0) at Component.cpp:38
        #12 0x00b2f98b in Null_Component (this=0x88287d0, id=0) at Null_Component.cpp:16
        #13 0x00b2cebe in libreverse::infrastructure::Component_Factory::get_Null_Component (this=0x8828768, id=0)
            at Component_Factory.cpp:83
        #14 0x00b091de in libreverse::api::Reverse::execute (this=0xbfcd1877, target_file=@0x8828484, input_type=@0x806acac,
            output_type=@0x806acf4) at Reverse.cpp:75
        #15 0x0805559a in main (ac=3, av=0xbfcd1a74) at reverse.cpp:50

At line 57 in Configuration_Parser is a cout statement using a
boost::format line. So with boost-1.33.1 there is something wrong when
you create a shared library with boost format and give the
BOOST_SP_ENABLE_HOOKS.

Here is my autoconf script where I set the debug flags. Perhaps I am
doing something here that is setting up the compiler to produce faulty
output:

        AC_ARG_ENABLE(debug,
            AC_HELP_STRING(--enable-debug, [Have GCC compile with
        symbols (Default = no)
        ]),
            enable_debug=$enableval, enable_debug=no)
        
        if test "$enable_debug" = "yes" ; then
            GCC_CFLAGS="-g3 -O0 -Wall -Werror -Wextra -DDEBUG"
            GCC_CXXFLAGS="-g3 -O0 -Wall -Werror -Wextra -DDEBUG"
        else
            GCC_CFLAGS="$CFLAGS -Werror -DNO_DEBUG"
            GCC_CXXFLAGS="$CXXFLAGS -Werror -DNO_DEBUG"
        fi
        
        AC_ARG_ENABLE(debug-boost-pointers,
                AC_HELP_STRING(--enable-debug-boost-pointers, [Turn debugging
        code for boost shared pointers]),
                enable_debug_pointers=$enableval, enable_debug_pointers=no)
        
        if test "$enable_debug_pointers" = "yes"; then
            GCC_CXXFLAGS="$GCC_CXXFLAGS -DBOOST_SP_ENABLE_DEBUG_HOOKS"
        fi

I don't know how just adding this flag to my system affects boost in
such a way that I get this segfault. Since I still so lost I cannot give
you a simple example saying "Compile and run this and you will see".

Stephen


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