I had on old C++ project starting a Console-application.
With a breakpoint in main(int argc, char** argv)
started program.exe -debug
.
According to the debugger argc became 32 and the strings in argv had weird random-like values.
When execution continued access violation occurred, since the strings in argv pointed to invalid values.
What can be causing this?
The linker had wrong Entry Point set.
For a normal console application this should be mainCRTStartup
(the debugger shows __tmainCRTStartup
).
Having an invalid entry point caused main to look at what "happended" to be in the stack.
Posting this since it was not trivial to find.