CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    chkstk.asm Error

    Hi,

    Code:
    Error message: Unhandled exception at 0x01A61CD7 in Test.exe: 0xC00000FD: Stack Overflow(Parameters: 0x00000000, 0x03212000)
    The call stack window displays like bellow:
    Code:
            Test.exe!_chkstk() Line 99	Unknown
     	Test.exe!_AfxDispatchCmdMsg(CCmdTarget * pTarget, unsigned int nID, int nCode, void (void) * pfn, void * pExtra, unsigned int nSig, AFX_CMDHANDLERINFO * pHandlerInfo) Line 81	C++
     	Test.exe!CCmdTarget::OnCmdMsg(unsigned int nID, int nCode, void * pExtra, AFX_CMDHANDLERINFO * pHandlerInfo) Line 381	C++
     	Test.exe!CDialog::OnCmdMsg(unsigned int nID, int nCode, void * pExtra, AFX_CMDHANDLERINFO * pHandlerInfo) Line 85	C++
     	Test.exe!CWnd::OnCommand(unsigned int wParam, long lParam) Line 2785	C++
     	Test.exe!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2151	C++
     	Test.exe!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2137	C++
     	Test.exe!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 290	C++
     	Test.exe!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 453	C++
    In my project, I have lot of fixed size array and its maximum size is 6000.
    But didn't receive this error before days.

    Problem started, when i'm using recursion function(Using Property sheet & Property Page ) after that only i'm getting this error.

    Is increase Stack Reserve Size / Stack Commit Size from Linker, solve this issue?
    Regards,

    SaraswathiSrinath

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: chkstk.asm Error

    Increasing the stack will shift the problem, it won't actually solve it unless you have a know absolute bound on stack usage.
    But even if you do know or have a bound, there are reasons to avoid excessive stack usage.

    Tips:
    - Don't use recursion unless you have guarantees about the maximum recursion depth. Then you can at least calculate the needed stack size. But in general any recursive solution that needs more than a few hundred Kb of stack should be converted into another approach. Either another algorithmic solution, or by 'unfolding' the recursion into an iterative approach.

    - Avoid large amounts of local data in a function (anything more than a few hundred bytes is "a lot"). Use allocated data to shift memory usage from stack to heap/free store. This is especially true for recursive functions.

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: chkstk.asm Error

    As you haven't posted any code, does the recursion function have an exit condition that will be fulfilled that will stop the recursion?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: chkstk.asm Error

    Quote Originally Posted by saraswathisrinath View Post
    Problem started, when i'm using recursion function(Using Property sheet & Property Page ) after that only i'm getting this error.
    The posted call stack shows no evidence of recursion...
    What is a "lot of fixed size array"? How many?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  5. #5
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Re: chkstk.asm Error

    Quote Originally Posted by OReubens View Post
    Increasing the stack will shift the problem, it won't actually solve it unless you have a know absolute bound on stack usage. But even if you do know or have a bound, there are reasons to avoid excessive stack usage.
    OK. But I don't know can i come out from this error.

    Quote Originally Posted by 2kaud View Post
    As you haven't posted any code, does the recursion function have an exit condition that will be fulfilled that will stop the recursion?
    I accept. it's hard to answer without seeing any code. But i can't to post my project. But i was created a sample code. but the same error not occurred.

    Quote Originally Posted by VladimirF View Post
    The posted call stack shows no evidence of recursion...
    What is a "lot of fixed size array"? How many?
    I don't known exactly is it a stack corruption or recursion error.
    Arr[7] - 6 numbers
    Arr[24] - 6 numbers
    Arr[31] - 6 numbers
    Arr[32] - 4 numbers
    Arr[60] - 6 numbers
    Arr[128] - 8 numbers
    Arr[255] - 5 numbers
    Arr[256] - 14 numbers
    Arr[512] - 6 numbers
    Arr[2048] - 3 numbers
    Arr[6144] - 1 number

    IS the problem solved , if i am using dynamic allocation of array and reallocation of array?
    Last edited by saraswathisrinath; May 9th, 2015 at 05:58 AM.
    Regards,

    SaraswathiSrinath

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: chkstk.asm Error

    It's possible you have a memory corruption issue which could have been present previously but which is only obvious now due to changed code.

    This is where the debugger becomes your friend to identify the issue.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #7
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Re: chkstk.asm Error

    Quote Originally Posted by 2kaud View Post
    It's possible you have a memory corruption issue which could have been present previously but which is only obvious now due to changed code.

    This is where the debugger becomes your friend to identify the issue.
    I will check.

    Pls find the attachment. I'm using the same concept.

    That is, Main dialog contains a button, when i click that button i called property sheet with one page. that page contain "open button". when i click the open button the recursion starts that is, I opened the same "property sheet with one page" again. but i never take care to close the previous sheet and page. may be its generate the errors.

    how can i close the "previous opened property sheet and page" using the "open button in page 1".
    Attached Files Attached Files
    Regards,

    SaraswathiSrinath

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: chkstk.asm Error

    Quote Originally Posted by saraswathisrinath View Post
    ... Main dialog contains a button, when i click that button i called property sheet with one page. that page contain "open button". when i click the open button the recursion starts that is, I opened the same "property sheet with one page" again. but i never take care to close the previous sheet and page. may be its generate the errors.
    Yes, it may generate the errors because of too many window and other handles would be created.

    Quote Originally Posted by saraswathisrinath View Post
    how can i close the "previous opened property sheet and page" using the "open button in page 1".
    To close a modal property sheet you should call EndDialog from within the sheet class.
    To close the modeless sheet - call DestroyWindow or send the WM_CLOSE message to its window from anywhere.
    Victor Nijegorodov

  9. #9
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Re: chkstk.asm Error

    Quote Originally Posted by VictorN View Post
    To close the modeless sheet - call DestroyWindow or send the WM_CLOSE message to its window from anywhere.
    Code:
    	GetParent()->PostMessageA(WM_CLOSE);
    		
    	CMasterDlg Dlg(this);	
    	CPage1 p1;		
    	Dlg.AddPage(&p1, CPage1::IDD);
    	if (Dlg.DoModal() == ID_WIZFINISH)
    	{}
    	else
    	{}
    After 25th click of open button, the page was hidden and the sheet only displayed.
    When i clicked ALT+TAB control, the pages showed like attached image. kindly find the attachment.
    Attached Images Attached Images  
    Regards,

    SaraswathiSrinath

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