CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    Join Date
    Feb 2009
    Posts
    54

    what is this non-sense error?

    The below crash happens during the constructor of a class that has a member that is a templatized "set"
    Happens only on Freebsd not on RHEL.
    Can someone please help? My project is stuck on this and am not even able to explain to superiors why I'm stuck. I've seen nothing as meaningless as this error.

    #0 __default_alloc_template<false, 0>::_Y_allocate (__n=32) at stlinst.cc:142
    #1 0x200baf3d in __default_alloc_template<false, 0>::_Y_allocate (__n=32)
    at /home/y/include/g++/stl_alloc.h:502
    #2 0x2011aeb9 in __default_alloc_template<false, 0>::allocate (__n=32) at stl/stl_alloc.h:436
    #3 0x20ad382e in simple_alloc<_Rb_tree_node<LibEntry>, __default_alloc_template<false, 0> >::allocate (__n=1) at /home/y/include/g++/stl_alloc.h:251
    #4 0x20ad2af4 in _Rb_tree_alloc_base<LibEntry, allocator<LibEntry>, true>::_M_get_node (
    this=0xb0254) at /home/y/include/g++/stl_tree.h:475
    #5 0x20ad416c in _Rb_tree_base<LibEntry, allocator<LibEntry> >::_Rb_tree_base (this=0xb0254,
    __a=@0x9fbff9d0) at /home/y/include/g++/stl_tree.h:491
    #6 0x20ad38bb in _Rb_tree<LibEntry, LibEntry, _Identity<LibEntry>, less<LibEntry>, allocator<LibEntry> >::_Rb_tree (this=0xb0254, __comp=@0x9fbff9cf, __a=@0x9fbff9d0)
    at /home/y/include/g++/stl_tree.h:653
    #7 0x20ad2bc0 in set<LibEntry, less<LibEntry>, allocator<LibEntry> >::set (this=0xb0254)
    at /home/y/include/g++/stl_set.h:75
    #8 0x20acffdd in RestppLibCache::RestppLibCache (this=0xb0248) at RestLibCache.cc:180

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: what is this non-sense error?

    You might want to provide some context with the code near line 180 of RestLibCache.cc, along with any relevant declarations.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Feb 2009
    Posts
    54

    Re: what is this non-sense error?

    Line 180 is just the default constructor

    RestppLibCache::RestppLibCache()
    {
    /* nothing to do... */
    }

    The relevant declarations are
    struct LibEntry;
    protected:
    typedef std::set<LibEntry> entries_t;
    entries_t m_entries;

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: what is this non-sense error?

    It's possible something in the program prior to that point is corrupting the heap. A tool like valgrind (on Linux) is usually best for pinpointing such issues.

  5. #5
    Join Date
    Feb 2009
    Posts
    54

    Re: what is this non-sense error?

    Then it should have crashed at some earlier spot after I set
    export MALLOC_CHECK_=2
    right? But it didn't.

    However I do believe something else is causing the crash because this started happening after some major refactorings across files (but not inside this file) . I just don't know how to catch the problem.

    Paul,
    As far as this class is concerned I think I have pasted all relevant code. As you can see in the stacktrace it crashes while instantiating the std::map<LibEntry> member. I don't see why what code precedes or surrounds it should matter.
    Last edited by BarefootGuy; October 12th, 2009 at 02:17 PM.

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    Re: what is this non-sense error?

    Quote Originally Posted by BarefootGuy View Post
    Then it should have crashed
    There is no "should of crashed" in the world of C++. Crashes are never and should never be expected to be "guaranteed" to occur.

    Regards,

    Paul McKenzie

  7. #7
    Join Date
    Apr 1999
    Posts
    27,449

    Re: what is this non-sense error?

    Quote Originally Posted by BarefootGuy View Post
    Then it should have crashed at some earlier spot after I set
    export MALLOC_CHECK_=2
    right? But it didn't.

    However I do believe something else is causing the crash because this started happening after some major refactorings across files (but not inside this file) . I just don't know how to catch the problem.
    Make sure you are rebuilding the entire source, and not just a few modules.

    Regards,

    Paul McKenzie

  8. #8
    Join Date
    Feb 2009
    Posts
    54

    Re: what is this non-sense error?

    Quote Originally Posted by Paul McKenzie View Post
    Make sure you are rebuilding the entire source, and not just a few modules.

    Regards,

    Paul McKenzie
    Yes sir, I'm rebuilding the entire source.

  9. #9
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: what is this non-sense error?

    Is there a version of valgrind available for the problematic system?

  10. #10
    Join Date
    May 2002
    Location
    Lindenhurst, NY
    Posts
    867

    Re: what is this non-sense error?

    Quote Originally Posted by BarefootGuy View Post
    I don't see why what code precedes or surrounds it should matter.
    You're obviously new to debugging C / C++.

    When you have an error related to malloc / free / new / delete, it's quite possible that its because of something you're doing in a completely different section of code from where your stack trace shows. For example, you could have deleted the same pointer twice somewhere. Now in your next new / malloc call (in a completely different section of code) you'll crash. Or, more accurately, you might crash, or you might not.

  11. #11
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: what is this non-sense error?

    The basic issue is that heap corruption can be caused anywhere, but only detected when you try to allocate or release memory (if then).

  12. #12
    Join Date
    Feb 2009
    Posts
    54

    Re: what is this non-sense error?

    May be as you say, but as per the code I've pasted, it is the stack memory that is involved, isn't it?

  13. #13
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: what is this non-sense error?

    A std::set will use heap memory internally.

    If you have valgrind, I'm sure that will pinpoint the problem quickly. Probably an "illegal write of size x" error.

  14. #14
    Join Date
    Feb 2009
    Posts
    54

    Re: what is this non-sense error?

    Quote Originally Posted by Lindley View Post
    Is there a version of valgrind available for the problematic system?
    I think valgrind is only for Linux, not Freebsd. I will try with some tool available for Freebsd in the morning. It is very late now.

  15. #15
    Join Date
    May 2002
    Location
    Lindenhurst, NY
    Posts
    867

    Re: what is this non-sense error?

    Quote Originally Posted by BarefootGuy View Post
    I think valgrind is only for Linux, not Freebsd. I will try with some tool available for Freebsd in the morning. It is very late now.
    Can you create an SSCCE that crashes on FreeBsd? Even though it won't crash on another OS, if you create a SSCCE, someone is more likely to be able to pinpoint your problem.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured