最近在写一个服务程序,在调试时发现运行一段时间后,程序会报“0XC00000FD”然后直接退出,且这个异常无法通过try catch捕捉,但是可以在系统日志中看到,查看微软文档发现这种错误基本由以下三种情况导致,排查自己写的代码,确认为第一种,无限递归导致,改为while do后正常。
A stack overflow is an error that user-mode threads can encounter. There are three possible causes for this error:
-
A thread uses the entire stack reserved for it. This is often caused by infinite recursion.
-
A thread cannot extend the stack because the page file is maxed out, and therefore no additional pages can be committed to extend the stack.
-
A thread cannot extend the stack because the system is within the brief period used to extend the page file.
refer to https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugging-a-stack-overflow