Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6081561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:11:24+00:00 2026-05-23T11:11:24+00:00

Can GDB detect call stack overflows typically in infinite recursion bugs and print some

  • 0

Can GDB detect call stack overflows typically in infinite recursion bugs and print some nice error and context message instead of the code given below which is very hard to understand for novices and very inconvenient for all of us. In this case it would be super-cool if GDB could detect which objects (pointers) that were involved in the infinite recursion loop by checking repetitive patterns in the (member-) function- or variable-pointers involved. I’m using gdb-7.3-dev on Ubuntu. Output follows:

Program received signal SIGSEGV, Segmentation fault.
0x008577e9 in _int_malloc (av=0x9483c0, bytes=4) at malloc.c:4249
4249    malloc.c: Filen eller katalogen finns inte.
    in malloc.c
(gdb) up
#1  0x00859f53 in __libc_malloc (bytes=4) at malloc.c:3660
3660    in malloc.c
(gdb) 
#2  0x00788b87 in operator new(unsigned int) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
(gdb) 
#3  0x0809cb7e in __gnu_cxx::new_allocator<Ob*>::allocate (this=0xbf80025c, __n=1)
    at /usr/include/c++/4.6/ext/new_allocator.h:92
92      return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
(gdb) 
#4  0x0809c7c8 in std::_Vector_base<Ob*, std::allocator<Ob*> >::_M_allocate (
    this=0xbf80025c, __n=1) at /usr/include/c++/4.6/bits/stl_vector.h:150
150       { return __n != 0 ? _M_impl.allocate(__n) : 0; }
(gdb) 
#5  0x0809c931 in std::vector<Ob*, std::allocator<Ob*> >::_M_insert_aux<Ob*> (
    this=0xbf80025c, __position=Cannot access memory at address 0x0
) at /usr/include/c++/4.6/bits/vector.tcc:324
324       pointer __new_start(this->_M_allocate(__len));
(gdb) up
#6  0x0809c65a in std::vector<Ob*, std::allocator<Ob*> >::emplace_back<Ob*> (
    this=0xbf80025c, __args#0=@0xbf800190) at /usr/include/c++/4.6/bits/vector.tcc:102
102       _M_insert_aux(end(), std::forward<_Args>(__args)...);
(gdb) 
#7  0x0809c5c4 in std::vector<Ob*, std::allocator<Ob*> >::push_back (this=0xbf80025c, 
    __x=@0xbf800190) at /usr/include/c++/4.6/bits/stl_vector.h:840
840       { emplace_back(std::move(__x)); }
(gdb) 

/Per

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:11:24+00:00Added an answer on May 23, 2026 at 11:11 am

    Gdb cannot really do this as the stack overflow detection is generally implemented by the compiler. The general way compilers implement this is with canaries. The canary is a value on the stack (the location is between the local variables and the stack frame) that is checked if it got overwritten. The problem with stack overflows is that you end with a damaged stack and the call stack is often not useful. A way around this is to set a watchpoint on the canary location with the br command. So it will break right at the point when the canary is getting overwritten

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason I can't get gdb to recognize the files in my project
How can I get GDB to print a stacktrace (e.g. to run the bt
In gdb, I can call one function with command call, but how can I
I am new to GDB, so I have some questions: How can I look
My gdb is GNU gdb Red Hat Linux (6.3.0.0-1.162.el4rh) and I can't debug templates.
I'm getting a segfault that GDB says is coming from SDL_GL_SwapBuffers. However, I can't
can you recommend some good ASP.NET tutorials or a good book? Should I jump
I have a pointer in GDB, how can I find out where it was
Can GDB be used to debug programs in languages other than C or C++,
How can I set Emacs gdb so that it shows the most recent command

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.