Boost logo

Boost Users :

From: Stephen Torri (storri_at_[hidden])
Date: 2007-03-23 21:08:21


On Fri, 2007-03-23 at 02:46 +0200, Peter Dimov wrote:
> Yes, there are a bunch of assertions in sp_debug_hooks that attempt to catch
> heap- and shared_ptr-related errors. Make sure you don't #define NDEBUG,
> though.
>
> If the asserts don't trigger, your problem might be deeper than a simple
> invalid use of shared_ptr. If you post a backtrace/call stack of one of your
> crashes, we may be able to help.

When I add the BOOST_SP_ENABLE_DEBUG_HOOKS to the compile flags for g++
I am getting a segmentation fault when the boost::format lines in my
code are executed. Yet when I compile without it I don't. Here is the
output from my project that is in development. It gives me a error from
the parser.

        $ ./reader --file kernel32.dll
        File to analyze was set to kernel32.dll.
        Parser_Base::Cannot find /home/storri/src/libreader/config.xml
        Exception throw in Parser_Base.cpp at line 37
        Unable to find the default setup files for the system.
        Starting the library using the default settings
        Data_Object::setData - Filename = kernel32.dll (Ptr count = 3,
        Input Ptr count = 3)
        Exception throw in Master_Formula_Parser.cpp at line 132
        Exception:(Parsing_Exception) 3
        Internal parsing error
        
When I compile it with BOOST_SP_ENABLE_DEBUG_HOOKS it fails with the
segfault:

        $ ./reader --file kernel32.dll
        File to analyze was set to kernel32.dll.
        Parser_Base::Cannot find /home/storri/src/libreader/config.xml
        Segmentation fault

        (gdb) bt
        #0 0x48029fa8 in std::operator<< <std::char_traits<char> > () from /usr/lib/libstdc++.so.6
        #1 0x0039cc7e in boost::io::detail::put_last<char, std::char_traits<char>, char [16]> (os=@0xbfa89674, x=@0x44584d)
            at /usr/include/boost/format/feed_args.hpp:98
        #2 0x0039cdaa in boost::io::detail::put<char, std::char_traits<char>, std::allocator<char>, char const (&) [16]> (
            x=@0x44584d, specs=@0x9969e48, res=@0x9969e4c, buf=@0xbfa89938, loc_p=0x0)
            at /usr/include/boost/format/feed_args.hpp:150
        #3 0x0039d549 in boost::io::detail::distribute<char, std::char_traits<char>, std::allocator<char>, char const (&) [16]> (
            self=@0xbfa89900, x=@0x44584d) at /usr/include/boost/format/feed_args.hpp:241
        #4 0x0039d5a8 in boost::io::detail::feed<char, std::char_traits<char>, std::allocator<char>, char const (&) [16]> (
            self=@0xbfa89900, x=@0x44584d) at /usr/include/boost/format/feed_args.hpp:251
        #5 0x0039d66e in boost::basic_format<char, std::char_traits<char>, std::allocator<char> >::operator%<char [16]> (
            this=0xbfa89900, x=@0x44584d) at /usr/include/boost/format/format_class.hpp:64
        #6 0x0039c06e in libreader::infrastructure::Parser_Base::parse_impl (this=0xbfa89bbc, file_ref=@0xbfa89b8c)
            at Parser_Base.cpp:38
        #7 0x0038d750 in libreader::infrastructure::Configuration_Parser::parse (this=0xbfa89bbc) at Configuration_Parser.cpp:31
        #8 0x003914fe in libreader::infrastructure::Configurator::Instance () at Configurator.cpp:31
        #9 0x0042f869 in libreader::infrastructure::Data_Source_Factory::Instance () at Data_Source_Factory.cpp:143
        #10 0x0037af5b in Component (this=0x99684c0, id=0) at Component.cpp:37
        #11 0x00377901 in Null_Component (this=0x99684c0, id=0) at Null_Component.cpp:16
        #12 0x00374e2a in libreader::infrastructure::Component_Factory::get_Null_Component (this=0x9968458, id=0)
            at Component_Factory.cpp:83
        #13 0x0035138e in libreader::api::reader::execute (this=0xbfa89fc7, target_file=@0x9968174, input_type=@0x806acac,
            output_type=@0x806acf4) at reader.cpp:68
        #14 0x0805559a in main (ac=3, av=0xbfa8a1c4) at reader.cpp:50
        
When I go to the code I see in Parser_Base.cpp at line a message that prints out above:

                std::cerr << boost::format("Exception throw in %s at line %d")
                    % __FILE__
                    % __LINE__
                          << std::endl;

__LINE__ is on line 37 in the file. The only change in the compile flags
from the pervious attempt was the flag to activate the code in
sp_debug_hooks.cpp that I included in the file. Any suggestions how I
can use the flag and the code to debug my original problem without
causing a new one?

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