Re: Access violation before startup in debug mode

Tech-Archive recommends: Speed Up your PC by fixing your registry



Actually, any illusion that it is "running" in release mode is probably just that: an
illusion. The point being that the debug mode detects what has broken, but the release
mode merrily uses bad data.

The most common form of this problem is in static initializers, but in fact if you enter
the debugger, it should ideally give you a traceback from NTDLL.DLL (alas, sometimes it
doesn't, which leads to sometimes single-stepping through assembly code in fascinating
ways to get an intact stack to show the traceback).

Start execution not with F5/run in debug mode but with F10/single step. If you get to
WinMain, the problem has not yet happened in the static initializers. Then start
single-stepping until it blows up. This will usually lead to useful information.
joe

On Tue, 12 Feb 2008 11:42:23 -0800 (PST), Rob Richardson <CedricCicada@xxxxxxxxx> wrote:

Greetings!

I have an MFC application that will run in release mode, but in debug
mode I get an access violation before the program starts. The only
error message is "Unhandled exception in ModelTest.exe (NTDLL.DLL):
0xC0000005: Access Violation." It doesn't give me any indication of
where the instruction is that raised the error. I put breakpoints at
the top of my InitInstance() method and on the line containing the
opening brace of my application constructor class, and neither
breakpoint is hit.

I also have an ActiveX control that does the same thing. When I try
running it in debug mode, it gives me an access violation
immediately.

Does anyone have any idea what might be causing this?

Thanks very much!

RobR
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Access violation before startup in debug mode
    ... I would expect your breakpoints to be ignored in release builds. ... I would start by writing some sort of log code and start strategically placing calls to this code until you can isolate where the error is occurring. ... mode I get an access violation before the program starts. ... running it in debug mode, it gives me an access violation ...
    (microsoft.public.vc.mfc)
  • VS.NET 2003, often wont stop at breakpoints, at wits end!
    ... Not stopping at breakpoints while ... debugging is a very common problem with my use of VS.NET 2003 and I'm ... their machines. ... to debug mode. ...
    (microsoft.public.vsnet.general)
  • Re: "There is no source code available for the current location"... what the?!?
    ... run in debug mode. ... Christopher A. Reed ... IS source code! ... error is what is keeping my breakpoints from working. ...
    (microsoft.public.dotnet.faqs)
  • Re: how to debug a service?
    ... Assuming the service is your project, build it in debug mode. ... Set any breakpoints that you want to set. ... Use the SCM to start ... Arnie ...
    (microsoft.public.vc.debugger)
  • irritating bug in debug
    ... but when I place breakpoints when running one of my ... applications in debug mode, they never appear where I want them to, ... Paul ...
    (microsoft.public.dotnet.languages.vb)