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.