Today, when you write a program, pop-up dialog boxes are displayed:
The application has an exception unknown software exception (0XC00000FD):
This is how the code reads a CSV file in a function, initializes a variable directly based on the size of the CSV file, and then reads and assigns the entire file to the variable at once.
At the beginning of the test is usually a small file of hundreds of K, there is no problem. When I choose a more than 1M picture, the above problem arises.
At first, from the error prompt, there is no hint that: stack overflow (stack overflow)
After setting a breakpoint in the code, find the key code: char Csv_content_ucs[filesize];
When the file is large, you need to open a large stack of space, beyond the system limits, will pop up the above error.
The solution is also simple: make and heap to store the data on the line malloc (fileSize)
Some online information about stack overflow (stack overflow):
Source: http://blog.csdn.net/zhongjling/article/details/8073796
Explain:
Generally, the stack space for each process is limited. (Why limit?) To learn the assembly and the operating system will know)
Generally 1M or 2M.
What occupies the stack space?
In addition to the system stack occupancy, basically is the stack variable. (What is a stack variable?) No language ¥%*&......%¥%&)
In short, the above is a stack variable.
There are two ways to modify:
Change to a heap variable:
int* pa = malloc (sizeof (int) *1000*1000);
The PA can then be used as an array. (Arrays and pointers are basically equivalent in C.)
Of course, no need to remember the free PA.
Two modification system limits
This stack variable = 1000*1000*4 = 4M. (approximately equals)
If this function is not frequently called and is not recursive, it will generally be acceptable.
You can modify the operating system size limit on the process stack space, slightly larger.
Ulimit View the limitations of the system. (*nix system command.) Not Windows)
Of course, method Two is not worth recommending
2014-06-26
Application exception unknown software exception (0XC00000FD) ...-Stack overflow (stack overflow)