CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2006
    Location
    Dallas, TX
    Posts
    47

    Status Stack Overflow

    Hey guys just wanted to know if i'm going nuts. Creating a recursive program. (Calling the function from within itself to loop it) How is it possible that calling the recursion causes a status stack overflow. I've done this process many times and never had this issue come up before.

    Here is the dump file if it's any help.

    Code:
    Exception: STATUS_STACK_OVERFLOW at eip=00410423
    eax=0008884C ebx=00000005 ecx=000322EC edx=0004B304 esi=00000008 edi=00000001
    ebp=0004B2F8 esp=0004B2E4 program=C:\Documents and Settings\Noah Blair\My Documents\CPP Projects\Sudoku2\Debug\Sudoku2.exe, pid 5036, thread main
    cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
    Stack trace:
    Frame     Function  Args
    0004B2F8  00410423  (000EBB64, 00000002, 00000001, 00000000)
    000EBB58  00401D24  (0018C4E0, 00000002, 00000001, 00000000)
    0022CCC8  004022C7  (00000001, 006C1370, 006C0090, 61010F8C)
    0022CD98  61006198  (00000000, 0022CDD0, 61005510, 0022CDD0)
    61005510  61004416  (0000009C, A02404C7, E8611001, FFFFFF48)
    1306078 [main] sudoku2 5036 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
    1333106 [main] sudoku2 5036 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)
    Thanks in advance

  2. #2
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: Status Stack Overflow

    How is it possible that calling the recursion causes a status stack overflow.
    Pretty simple: This recursion has recursed too deeply.
    In other words, there are two many stack frames of your function at the same time.
    That may happen if there are too many levels of recursion, or if each stack frame is huge, for example, if you use an automatic variable of array type.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

  3. #3
    Join Date
    Nov 2006
    Location
    Barcelona - Catalonia
    Posts
    364

    Re: Status Stack Overflow

    Hi,
    If you make a very deep recursion or you have many non-dynamic variables you can overflow the amount of stack memory.
    I think this article can helps you.
    If you are using VC++ you can override the amount of memory reserved for stack, in this way:
    Code:
    #pragma comment (linker, "/STACK:0x500000")
    VC++ reserves 1Mb of memory for stack this preprocessor directive raises it up to 5Mb.
    I'm sure there's another way if you are using another compiler, read its documentation.
    However, I think this is not the better way, I think is better build your automatic variables dynamic.

    Albert.
    Please, correct me. I'm just learning.... and sorry for my english :-)

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