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.

Faulting application name: dbow2_orb_gpw.exe, version: 0.0.0.0, time stamp: 0x5d8750b5
Faulting module name: dbow2_orb_gpw.exe, version: 0.0.0.0, time stamp: 0x5d8750b5
Exception code: 0xc00000fd
Fault offset: 0x0000000000017cd8
Faulting process id: 0x550c
Faulting application start time: 0x01d57132ded05496
Faulting application path: F:\yandex\YandexDisk\cpp\dbow2\x64\Release\dbow2_orb_gpw.exe
Faulting module path: F:\yandex\YandexDisk\cpp\dbow2\x64\Release\dbow2_orb_gpw.exe
Report Id: eb3d7436-4144-43a6-acce-a3a294e27135
Faulting package full name:
Faulting package-relative application ID:

 

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.