Tracking down Access Violations

John Demme me at teqdruid.com
Thu May 18 17:51:39 PDT 2006


Jeremy wrote:

> My program is starting to get fairly large, and all seems to be going
> fairly well...
> 
> UNTIL this "Error: Access Violation" started popping up. I'm not sure
> where it is coming from, and I've been having a hard time tracking it
> down.
> 
> What is the best way to track these down? In some C/C++ applications, I
> could actually get one of those 'Illegal Operation' windows from Windows
> XP, which would tell me the instruction address, and then I could do an
> object dump to see which assembly instruction messed it up: but D just
> says "Error: Access violation" and that's it :(
> 
> The "-g" option gives me "forward reference" errors so I cannot run it
> through a debugger and get good results (correct?).
> 
> It seems like the only good way to do this is to keep commenting out code
> until it doesn't happen anymore (but the error is hard to reproduce, so
> it's hard to know if it just hasnt happened yet or not). Or -- add in
> debug writefln's everywhere and see when they stop.
> 
> There should be a better way I hope?

I dunno about access violations, but when I get a segfault on Linux, I run
it through GDB and it gives me a backtrace... I don't need debugging
information to get a backtrace-- the debugging information would just give
me the line number of the error, without it I can at least get the method
which the error is in.

~John Demme



More information about the Digitalmars-d mailing list