MFC Stack Overflow test DWORD ptr [Eax],eax; Probe page.

Source: Internet
Author: User

Today when debugging the program, found a strange problem, before debugging all no problem, this morning added a bit of something, error, jump to debug position, below 4 lines red section

1 ; Find next lower page and probe2cs20:3        Sub     eax, _pagesize_         ; decrease by PAGESIZE4        test    dword ptr [Eax],eax     ; Probe page. 5         jmp short       cs1067_chkstk ENDP89         End

Feel good strange, and then debugging breakpoints, even the entrance of the program has not entered the error, good depressed.

Then Baidu, originally because the local variable application space is too large, more than 1M.

The application space for local variables is stored in the stack, and the default stack memory in Windows is 1M, so overflow error occurs when the request space is greater than 1M.

Looking at the source code, originally added a struct array this morning, the array is beyond the size of the stack.

The following definitions are in the class:

    // Color Luminance Data    struct Lxy    {        float// brightness        float // chroma x        float // Chroma y     };     // entire picture data    

Other than that

1 #define Width  640  // pixels wide 2#define highth 480  // pixel height

In this way, the space occupied by this array is 640*480* (4+4+4) = 3686400B = 3600KB = 3.515625M

In this case, the solution is to modify the definition of the array into a dynamic array

1 carray<lxy,&lxy> lxydata;

or expand the size of the stack space.

The way to enlarge the size of the space stack is

Project->properties->configuarations Properties->linker->system->stact Reserve Size

For example, modify to 5M, you can enter 5242880

1024*1024*5 = 5242880

This will allow the program to function as it is modified.

two sons

MFC Stack Overflow test DWORD ptr [Eax],eax; Probe page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.