Hi,
Ah, yes, these are tricky yet easy to remember.
The following is usually meant for advanced users, but for sake
of newbies, I'll explain the full story below:
This "exception" with access violation (either NULL constant or a
memory address) means that KeySoft was trying to read a memory
location that it does not have access to. For example, if
KeySoft was trying to read a value from a memory location but the
OS says that it isn't a legal address or a legal memory content,
the OS will throw (inform) an exception to KeySoft, letting the
user know that it didn't work. As an example, consider the
following C++ statement (or, if you know Java, Python or similar,
you can write it using your language):
int test = 5; // We've declared a variable called test (an
integer type) and told it to hold a value of 5.
int* test_ptr = &test; // This means that we wish to use a
pointer variable to store the address of the test variable.
cout << *test_ptr << endl; // Here, we told the program to print
the value stored at the test variable by doing what programmers
call "dereferencing." If we just used test pointer without the
asterisk at the front, the program would output the memory
location (address) where the variable "test" resides; in order to
get the value of that variable via pointer, you need to include
asterisk to tell the program that we wish to output the value 5.
The above is legal, which results in no exception. However,
consider the following code:
int test = 5;
int* test_ptr = NULL; // NULL is a constant that says that the
pointer should point to address location zero.
cout << *test_ptr << endl;
Well, this code compiles fine (translated correctly to machine
code), but if we ask this program to run and execute (perform)
the last instruction, you'll get an exception that says: "access
violation reading 0." This essentially means that this program
was trying to output something which was stored on memory address
0 (NULL address), which is illegal; it may seem okay to
developers, but the OS says, "no, you can't do that because you
can't really read from address zero."
Another variant of this error is if a program was trying to read
an address that it does not have access to. For instance,
suppose that we have two programs (one a system software and
another a user program) using the same memory location named
1000. Consider:
int* memory_ptr = &somefile; // Just a hypothetical example that
asks the pointer var to be located where the file address is
located.
cout << *memory_ptr << endl;
If the "somefile" value contained a valid value like an integer,
it would succeed and tell you the value; however, if "somefile"
is being used by another program, or if the value type is not the
value type of the pointer (like if the value was a string but the
pointer type was an int), it'll not work - at worst, it'll throw
an exception saying that you cannot read from this particular
address where "somefile" is located.
Now for others: a computer's memory can be thought of as a long
street with houses on either side (rather, a grid or a fork for
streets). Just like the real world, houses have addresses and
there's bound to be no or one or more occupants. There are
special addresses in this street (or streets) that the mailman
cannot 1esss simply he is not told to access it or the supervisor
says that a higher ranked official is visiting that house.
Reading a value from memory can be thought of as if a girl wishes
to visit her friend somewhere on the street. First, she needs to
know the address of her friend's house; once she found the house,
she'll knock and ask if her friend is there (in this case, her
friend is there). Then she and her friend does some activities
and, when they're done, her friend will be dropped off at her
house.
Similarly, writing to a memory location can be thought of as move
in day for a family. This family, being informed by a real
estate agent that certain house at certain address is empty,
decides to move there. But that means rearranging the existing
furniture around the supposed empty house.
To illustrate Tyler's query using our street example, consider
two scenarios:
Scene 1: farmer wishes to grow rice or corn on one of the street
addresses, but the only availible address was "address zero."
When the farmer goes there, he finds that the ground is filled
with trash and it is not a good soil for farming. Despite all
his attempts at cleaning this mess, the farmer gets frustrated
and asks the city clerk to designate this address as "unusable."
Then the city clerk puts a sign at that address, saying, "anyone
who attempts to build something here or tries to find out what's
burried under here will be fined." This scenario describes
"access violation reading/writing 0."
Scene 2: We have a bank that had a history of robbery. One day,
the city officials came to investigate a high-profile robbery
from this bank, which is next to a house that belongs to this
bank's customer. When the customer goes to the bank to withdraw
some money, she is told that the bank is closed for
investigation. Other customers comes in, and finds that the bank
will be closed for two days because of the robbery investigation
despite their attempts to deposit or withdraw money. This is a
typical example of "access violation reading/writing memory
address."
I guess this is enough for today - going further means we need to
explore how memory manager works under OS's, which is way
advanced.
Cheers,
Joseph
----- Original Message -----
From: Tyler <[email protected]
To: [email protected]
Date sent: Sat, 11 Feb 2012 16:19:38 -0500
Subject: [Braillenote] crazy errors
Right now, my Mpower is free of errors, but, sometimes, there
will be one. Obviously, my Braillenote
is working fine now, but I'm curious what the errors mean if they
ever come up. I can't give you any
of the error code numbers, but various file opening will
sometimes throw an exception. "Exception, command"
something about access violation. Just in case I ever get the
message again. Remember those words. Access
violation.
Tyler Z
___
Replies to this message will go directly to the sender.
If your reply would be useful to the list, please send a
copy to the list as well.
To leave the BrailleNote list, send a blank message to
[email protected]
To view the list archives or change your preferences, visit
http://list.humanware.com/mailman/listinfo/braillenote