Dangling pointer

A hanging pointer (English dangling pointer) referred to in the computer science a pointer that contains an invalid value and thus refers to a nonexistent or not the pointer assigned storage area.

Hanging pointers often come thus concluded that they have been initialized (in the case alternatively called wild pointers ) - but also by the fact that they refer to a memory area that has already been freed.

Hanging pointers for the program run in unpredictable behavior and cause the program to crash. While userspace programs usually at a dereference of a wild pointer ended, such a kernel or at worst damage the modules, the entire system without the user noticing something before it is too late, because no supervisory authority exists, which could prevent, for example, the overwriting of foreign code. Therefore, please pay particular attention to the correct use of the kernel and driver development.

The unpredictability stems from the fact that access to a pre- shared memory area is not necessarily immediately a runtime error ( access violation ) triggers, as between the memory release by the programmer and the actual release by the runtime system can still pass some time. Find in this ( unpredictable ) Meanwhile, another access to the shared memory instead ( line (*) in the example), it will not cause an error. Since this is not reproducible, these sporadic errors are particularly insidious.

Example

C

# include   using namespace std;   int main () {      int * pPointer = new int; / / Pointer of the type applied integer      cout << pPointer; / / This would display the memory address in the heap      delete pPointer; / Release / storage      cout << pPointer; / / Displays still the memory address in the heap to,                                / / Even though it was release => Dangling Pointer      / / * PPointer = 10; / / (*) Have access to this pointer would (or can ) causes a fatal error      pPointer = 0; / / PPointer is now no dangling pointer more, see Null Pointer      return 0; } It is a sign of good programming style after a delete to set the pointer to 0, even if it is no longer referred to the pointer.

214537
de