Thread overview
Access voilation ?
Sep 05, 2004
Sai
Sep 05, 2004
antiAlias
Sep 08, 2004
Sai
Sep 07, 2004
J C Calvarese
September 05, 2004
Can any one please tell me what exactly causes "Access Voilation" runtime error ?

I am haunted by it all the times.

I am despererately missing the call stacktrace of java and c#.
is it difficult to get call stack trace in D when an app crashes ?

I am sorry I have no clue of how compilers work.

Thanks
Sai


September 05, 2004
The most frequent reason for this is mistaken usage of printf(). If you're
trying to use a char[] with printf(), you must use the "%.*s" format rather
than "%s". Alternatively, use writef() instead.

Second most frequent error seems to be using a class 'instance' without assigning it. For example:

Class X {void foo(){}}

void main()
{
   X x;

   x.foo();  // access violation

   x = new X;
   x.foo();  // correct
}

Other, more esoteric, reasons relate to static constructors.

Good luck;


"Sai" <Sai_member@pathlink.com> wrote in message
news:chffpa$esi$1@digitaldaemon.com...
Can any one please tell me what exactly causes
"Access Voilation" runtime error ?

I am haunted by it all the times.

I am despererately missing the call stacktrace of java and c#.
is it difficult to get call stack trace in D when an app crashes ?

I am sorry I have no clue of how compilers work.

Thanks
Sai



September 06, 2004
if you're looking for a techincal description, it's caused when a program attempts to access memory that it's not allowed to.  hence, a "violation." back in the old days, there was real mode, where any program could affect any other part of memory.  this was bad.  programs could very easily crash the entire computer just by writing some stupid values to the right place in memory.  also if a program went astray and got stuck in an endless loop of writing stuff to memory, it could also crash the entire computer.  so they invented protected mode, where each program is only allowed to touch certain parts of memory, and if it tries to touch other things, it gets scolded.

probably 90% of the time MAVs are caused by "off-by-one" errors - that is, you write past the end of an array by just one element.  D has array bounds checking in debug mode, so at least it's a little more descriptive than "memory access violation".  another big cause is trying to use a dead (deleted) pointer, or when dealing with COM.  oh how i hate COM.


September 07, 2004
Sai wrote:
> Can any one please tell me what exactly causes "Access Voilation" runtime error ?

Various problems can lead to "Access Violations". Here's some of the common ones:

http://www.prowiki.org/wiki4d/wiki.cgi?ErrorMessages#RuntimeErrors

> 
> I am haunted by it all the times.
> 
> I am despererately missing the call stacktrace of java and c#.
> is it difficult to get call stack trace in D when an app crashes ? 
> 
> I am sorry I have no clue of how compilers work.
> 
> Thanks
> Sai
> 
> 


-- 
Justin (a/k/a jcc7)
http://jcc_7.tripod.com/d/
September 08, 2004
Thanks to antiAlias and Jarrett, that was very informative. I was
not using debug mode at all (may be overconfidence ;),
debug mode caught almost all the bugs.

Sai


In article <chhumd$1eom$1@digitaldaemon.com>, Jarrett Billingsley says...
>
>if you're looking for a techincal description, it's caused when a program attempts to access memory that it's not allowed to.  hence, a "violation." back in the old days, there was real mode, where any program could affect any other part of memory.  this was bad.  programs could very easily crash the entire computer just by writing some stupid values to the right place in memory.  also if a program went astray and got stuck in an endless loop of writing stuff to memory, it could also crash the entire computer.  so they invented protected mode, where each program is only allowed to touch certain parts of memory, and if it tries to touch other things, it gets scolded.
>
>probably 90% of the time MAVs are caused by "off-by-one" errors - that is, you write past the end of an array by just one element.  D has array bounds checking in debug mode, so at least it's a little more descriptive than "memory access violation".  another big cause is trying to use a dead (deleted) pointer, or when dealing with COM.  oh how i hate COM.
>
>