Electric Fence
Encyclopedia
Electric Fence is a memory debugger
Memory debugger
A memory debugger is a programming tool for finding memory leaks and buffer overflows. These are due to bugs related to the allocation and deallocation of dynamic memory. Programs written in languages that have garbage collection, such as managed code, might also need memory debuggers, e.g...

 written by Bruce Perens
Bruce Perens
Bruce Perens is a computer programmer and advocate in the open source community. He created the Open Source Definition and published the first formal announcement and manifesto of open source. He co-founded the Open Source Initiative with Eric S...

. It consists of a library which programmers can link into their code to override the C standard library
C standard library
The C Standard Library is the standard library for the programming language C, as specified in the ANSI C standard.. It was developed at the same time as the C POSIX library, which is basically a superset of it...

 memory management
Memory management
Memory management is the act of managing computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to the computer system.Several...

 functions. eFence triggers a program crash when the memory error occurs, so a debugger
Debugger
A debugger or debugging tool is a computer program that is used to test and debug other programs . The code to be examined might alternatively be running on an instruction set simulator , a technique that allows great power in its ability to halt when specific conditions are encountered but which...

 can be used to inspect the code that caused the error.

Electric Fence is intended to find two common types of programming bugs:
  • Overrunning the end (or beginning) of a dynamically allocated buffer
  • Using a dynamically allocated buffer after returning it to the heap

In both cases, Electric Fence causes the errant program to abort immediately via a segmentation fault. Normally, these two errors would cause heap corruption, which would manifest itself only much later, usually in unrelated ways. Thus, Electric Fence helps programmers find the precise location of memory programming errors.

Electric Fence allocates at least two pages (often 8KB) for every allocated buffer. In some modes of operation, it does not deallocate freed buffers. Thus, Electric Fence vastly increases the memory requirements of programs being debugged. This leads to the recommendation that programmers should apply Electric Fence to smaller programs when possible, and should never leave Electric Fence linked against production code.

Electric Fence is free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 licensed under the GNU General Public License
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....

. Last version (2.1.13) was released 2003-12-07.

External links

  • eFence – source code
  • DUMA – a fork of Electric Fence
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK