Storage violation

From Wikipedia, the free encyclopedia

A Storage violation is an attempt at, or successful alteration ("or corruption") of computer memory that is intended to have the special status of "protected" (that is - not alterable - at least in the current mode of operation).

It normally applies to selected memory locations having special significance to the operating system or "owned" by a particular thread.

Computer storage (another term for memory), is often dynamically allocated from a pool of available memory for a particular "process" such as a program subroutine call. For instance, if one megabyte of memory is available for several concurrent applications to use, each application may request its own 'section' of this memory for its own use.

The application may further sub-divide its own allocated memory to process internal functions such as saving Stack (data structure), working memory and bitmap images.

A common type of Storage violation is known as a stack buffer overflow where a program attempts to alter a memory location beyond its' allocated memory. For instance, a "storage violation" occurs if the program tries to alter the eleventh element of an array ("table") of only 10 entries (elements) in size. Imagine an array of 10 x 4-letter words in an allocated memory of 40 bytes.

The memory at the address of the eleventh entry may belong to another application program or another thread of the same application. If this is so, the other application now has corrupted memory without necessarily being aware of it. This has traditionally been the source of many unsolved system crashes within computing and sometimes referred to as "Action at a distance (computer science)". The use of pointers in some Programming languages makes it easier to corrupt storage if the pointers are incremented beyond their appropriate range at any given point during execution.

Use of a corrupt Goto address (sometimes known as a "Wild branch") may also result in execution of code which results in possibly random execution of perfectly valid instructions - but almost certainly completely out of context with appropriate register values for that code. In this case, the "COMEFROM" address may be extremely difficult or even impossible to determine without suitable instruction tracing or monitoring software (but invoked prior to the error occurring - if an exact rerun is even possible - which, in high volume, real-time transaction processing, is seldom the case).

In some instances, it is necessary to switch into privileged mode to enable storage alteration to be successful. This is normally achieved by a special instruction which itself might be privileged.

This right or "privilege" may only be authorized for some users or software or systems on a higher level of operation such as the Operating System itself.

[edit] Prevention

Some programming languages use software Bounds checking to prevent these occurrences. Some program debugging software will also detect violations during testing.

Some computer hardware protection features can be used to prevent these too but generally operate on larger blocks of memory than might be appropriate for a given process.

Operating systems generally execute in a "privileged" mode allowing their instructions to alter storage at any location in memory.

[edit] See also