Name: Anonymous 2012-10-27 7:04
What does it mean when my own Win32 app randomly exits with error code 1 (apparently ERROR_INVALID_FUNCTION according to MSDN), despite it not being programmed to do so?
I've been trying to find the bug in the code for hours, with no success. There are 2000 lines of code. I tried setting up exception handlers so I could see if it's a segmentation fault (SetUnhandledExceptionFilter lets me debug the address where the error occurred), but the problem is really weird in this case: the exception filter is never triggered, nor does the app pop up the usual "Report Error To Microsoft" dialog if I don't set an exception handler. I first thought it's a stack overflow since those don't pop up a dialog, but after some testing I realized the UnhandledExceptionFilter actually detects stack overflows, so it isn't that (the filter is not triggered by the bug, nor can I find anything that could possibly cause a stack overflow from the code).
There are no ExitProcess/ExitThread calls in the process that return a "1". "1" is never returned by the main() function. The process does not leak memory. Large structs are not pushed on the stack.
As I said, address-based debugging is not an option since the process exits normally with code 1. That's why I am asking what could possibly cause a process to auto-return the value "1" in 32-bit Windows XP.
This bug is randomly triggered, which makes debugging even harder since the code executes dozens of functions millions of times. No specific function seems to be the cause of the bug. The process can sometimes run just fine for hours, and then begins crashing randomly every minute or so. Currently I'm using a program that simply restarts the process if it crashes, but I'm looking for the source of the problem..
I've been trying to find the bug in the code for hours, with no success. There are 2000 lines of code. I tried setting up exception handlers so I could see if it's a segmentation fault (SetUnhandledExceptionFilter lets me debug the address where the error occurred), but the problem is really weird in this case: the exception filter is never triggered, nor does the app pop up the usual "Report Error To Microsoft" dialog if I don't set an exception handler. I first thought it's a stack overflow since those don't pop up a dialog, but after some testing I realized the UnhandledExceptionFilter actually detects stack overflows, so it isn't that (the filter is not triggered by the bug, nor can I find anything that could possibly cause a stack overflow from the code).
There are no ExitProcess/ExitThread calls in the process that return a "1". "1" is never returned by the main() function. The process does not leak memory. Large structs are not pushed on the stack.
As I said, address-based debugging is not an option since the process exits normally with code 1. That's why I am asking what could possibly cause a process to auto-return the value "1" in 32-bit Windows XP.
This bug is randomly triggered, which makes debugging even harder since the code executes dozens of functions millions of times. No specific function seems to be the cause of the bug. The process can sometimes run just fine for hours, and then begins crashing randomly every minute or so. Currently I'm using a program that simply restarts the process if it crashes, but I'm looking for the source of the problem..