C++ program terminates unexpectedly with error stack overflow [Exception code: 0xc00000fd]

Executed a c++ program using visual studio 2017. The program has a recursive loop and that caused the program to terminate unexpectedly without showing any error.

The windows event viewer showed the error code 0xc00000fd.


event viewer showing application error

Solution for Visual Studio:

  1. Go to solution explorer and select your project
Linker set stack size to overcome stack overflow error

2. Right Click on project and select Properties.

Linker set stack size (to overcome stack overflow error)

3. Go to Linker -> System -> Set Stack Reserve Size = 400000000, which is Hex equivalent of 1 GB of the stack, you can define your own size in HEX.

Linker set stack size (to overcome stack overflow error)

4. Now, go to Linker -> All Options and Set Stack Reserve Size = 400000000

Linker set stack size (to overcome stack overflow error)

5. Now Click Apply and Go to Command Line and verify the term /STACK:”400000000″

Linker command line parameter verification of stack size (to overcome stack overflow error)

6.  Go to C++ -> Command Line -> In Additional Options, Add /F 400000000

C++ command line parameter to set size of stack (to overcome stack overflow error)

Execute the program and enjoy.


Solution for command-line execution:

Add a parameter of /STACK:”4000000” with other linker parameters and /F 400000000 with compiling parameters.

In case if the program terminates again, try to increase the size to 800000000 for 2GB Stack.



Leave a Reply

Your email address will not be published. Required fields are marked *