login/register

Snip!t from collection of Alan Dix

see all channels for Alan Dix

Snip
summary

Magic debug values
Magic debug values are specific values written to memory ...
Since it is very unlikely, although possible, that a 32- ...
Famous and common examples include:
... in a live environment to reduce errors[citation needed].

Magic number (programming) - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/Magic_number_(programming)

Categories

/Channels/techie/debugging

[ go to category ]

For Snip

loading snip actions ...

For Page

loading url actions ...

Magic debug values

Magic debug values are specific values written to memory during allocation or deallocation, so that it will later be possible to tell whether or not they have become corrupted, and to make it obvious when values taken from uninitialized memory are being used. Memory is usually viewed in hexadecimal, so memorable repeating or hexspeak values are common. Numerically odd values may be preferred so that processors without byte addressing will fault when attempting to use them as pointers (which must fall at even addresses). Similarly, they may be chosen so that they are not valid codes in the instruction set for the given architecture.

Since it is very unlikely, although possible, that a 32-bit integer would take this specific value, the appearance of such a number in a debugger or memory dump most likely indicates an error such as a buffer overflow or an uninitialized variable.

Famous and common examples include:

Magic debug values
Code Description
..FACADE Used by a number of RTOSes
8BADF00D Used by Apple as the exception code in iPhone crash reports when an application has taken too long to launch or terminate.
A5A5A5A5 Used in embedded development because the alternating bit pattern (10100101) creates an easily recognized pattern on oscilloscopes and logic analyzers.
ABABABAB Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after allocated heap memory
ABADBABE Used by Apple as the "Boot Zero Block" magic number
ABADCAFE A startup to this value to initialize all free memory to catch errant pointers[clarification needed]
BAADF00D Used by Microsoft's LocalAlloc(LMEM_FIXED) to mark uninitialised allocated heap memory
BADBADBADBAD Burroughs large systems "uninitialized" memory (48-bit words)
BADC0FFEE0DDF00D Used on IBM RS/6000 64-bit systems to indicate uninitialized CPU registers
BADCAB1E Error Code returned to the Microsoft eVC debugger when connection is severed to the debugger
BADDCAFE On Sun Microsystems' Solaris, marks uninitialised kernel memory (KMEM_UNINITIALIZED_PATTERN)
BEEFCACE Used by Microsoft .NET as a magic number in resource files
C0DEDBAD A memory leak tracking tool which it will change the MMU tables so that all references to address zero
CAFEBABE Used by both Universal Mach-O binaries and Java .class files
CAFEFEED Used by Sun Microsystems' Solaris debugging kernel to mark kmemfree() memory
CCCCCCCC Used by Microsoft's C++ debugging runtime library to mark uninitialised stack memory
CDCDCDCD Used by Microsoft's C++ debugging runtime library to mark uninitialised heap memory
CEFAEDFE Seen in Intel Mach-O binaries on Apple Inc.'s Mac OS X platform (see FEEDFACE)
DDDDDDDD Used by MicroQuill's SmartHeap and Microsoft's C++ debugging heap to mark freed heap memory
DEADBABE Used at the start of Silicon Graphics' IRIX arena files
DEADBEEF Famously used on IBM systems such as the RS/6000, also used in the original Mac OS operating systems, OPENSTEP Enterprise, and the Commodore Amiga. On Sun Microsystems' Solaris, marks freed kernel memory (KMEM_FREE_PATTERN)
DEADDEAD A Microsoft Windows STOP Error code used when the user manually initiates the crash.
DEADF00D Used by Mungwall on the Commodore Amiga to mark allocated but uninitialised memory [12]
DEADFA11 Used by Apple as the exception code in iPhone crash reports when the user has force-quit the application.
EBEBEBEB From MicroQuill's SmartHeap
FADEDEAD Comes at the end to identify every AppleScript script
FDFDFDFD Used by Microsoft's C++ debugging heap to mark "no man's land" guard bytes before and after allocated heap memory
FEE1DEAD Used by Linux reboot() syscall
FEEDFACE Seen in PowerPC Mach-O binaries on Apple Inc.'s Mac OS X platform. On Sun Microsystems' Solaris, marks the red zone (KMEM_REDZONE_PATTERN)
FEEEFEEE Used by Microsoft's HeapFree() to mark freed heap memory

Note that most of these are each 32 bits long — the dword size of 32-bit architecture computers.

The prevalence of these values in Microsoft technology is no coincidence; they are discussed in detail in Steve Maguire's book Writing Solid Code from Microsoft Press. He gives a variety of criteria for these values, such as:

  • They should not be useful; that is, most algorithms that operate on them should be expected to do something unusual. Numbers like zero don't fit this criterion.
  • They should be easily recognized by the programmer as invalid values in the debugger.
  • On machines that don't have byte alignment, they should be odd numbers, so that dereferencing them as addresses causes an exception.
  • They should cause an exception, or perhaps even a debugger break, if executed as code.

Since they were often used to mark areas of memory that were essentially empty, some of these terms came to be used in phrases meaning "gone, aborted, flushed from memory"; e.g. "Your program is DEADBEEF".

Pietr Brandehörst's ZUG programming language initialized memory to either 0000, DEAD or FFFF in development environment and to 0000 in the live environment, on the basis that uninitialised variables should be encouraged to misbehave under development to trap them, but encouraged to behave in a live environment to reduce errors[citation needed].

HTML

<h2><span class="mw-headline" id="Magic_debug_values">Magic debug values</span></h2> <p><b>Magic debug values</b> are specific values written to <a href="/wiki/Random-access_memory" title="Random-access memory">memory</a> during <a href="/wiki/Memory_allocation" title="Memory allocation" class="mw-redirect">allocation</a> or deallocation, so that it will later be possible to tell whether or not they have become corrupted, and to make it obvious when values taken from uninitialized memory are being used. Memory is usually viewed in hexadecimal, so memorable repeating or <a href="/wiki/Hexspeak">hexspeak</a> values are common. Numerically odd values may be preferred so that processors without byte addressing will fault when attempting to use them as pointers (which must fall at even addresses). Similarly, they may be chosen so that they are not valid codes in the instruction set for the given architecture.</p> <p>Since it is very unlikely, although possible, that a 32-bit integer would take this specific value, the appearance of such a number in a <a href="/wiki/Debugger">debugger</a> or <a href="/wiki/Memory_dump" class="mw-redirect" title="Memory dump">memory dump</a> most likely indicates an error such as a buffer overflow or an uninitialized variable.</p> <p>Famous and common examples include:</p> <table class="wikitable"> <caption>Magic debug values</caption> <tbody><tr> <th style="background: none repeat scroll 0% 0% rgb(208, 224, 255);">Code</th> <th style="background: none repeat scroll 0% 0% rgb(208, 224, 255);">Description</th> </tr> <tr> <td><code>..FACADE</code></td> <td>Used by a number of <a href="/wiki/Real-time_operating_system" title="Real-time operating system">RTOSes</a></td> </tr> <tr> <td><code>8BADF00D</code></td> <td>Used by <a href="/wiki/Apple_Inc." title="Apple Inc.">Apple</a> as the exception code in <a href="/wiki/IPhone">iPhone</a> crash reports when an application has taken too long to launch or terminate.</td> </tr> <tr> <td><code>A5A5A5A5</code></td> <td>Used in embedded development because the alternating bit pattern (10100101) creates an easily recognized pattern on <a href="/wiki/Oscilloscope" title="Oscilloscope">oscilloscopes</a> and <a href="/wiki/Logic_analyzer" title="Logic analyzer">logic analyzers</a>.</td> </tr> <tr> <td><code>ABABABAB</code></td> <td>Used by <a href="/wiki/Microsoft">Microsoft</a>'s HeapAlloc() to mark "no man's land" <a href="/wiki/Guard_byte" title="Guard byte">guard bytes</a> after allocated heap memory</td> </tr> <tr> <td><code>ABADBABE</code></td> <td>Used by <a href="/wiki/Apple_Inc." title="Apple Inc.">Apple</a> as the "Boot Zero Block" magic number</td> </tr> <tr> <td><code>ABADCAFE</code></td> <td>A startup to this value to initialize all free memory to catch errant pointers<sup class="noprint Inline-Template" title="The text in the vicinity of this tag needs clarification or removal of jargon from June 2010" style="white-space: nowrap;">[<i><a href="/wiki/Wikipedia:Please_clarify" title="Wikipedia:Please clarify">clarification needed</a></i>]</sup></td> </tr> <tr> <td><code>BAADF00D</code></td> <td>Used by <a href="/wiki/Microsoft">Microsoft</a>'s LocalAlloc(LMEM_FIXED) to mark uninitialised allocated heap memory</td> </tr> <tr> <td><code>BADBADBADBAD</code></td> <td><a href="/wiki/Burroughs_large_systems">Burroughs large systems</a> "uninitialized" memory (48-bit words)</td> </tr> <tr> <td><code>BADC0FFEE0DDF00D</code></td> <td>Used on <a href="/wiki/IBM">IBM</a> <a href="/wiki/RS/6000">RS/6000</a> 64-bit systems to indicate uninitialized CPU registers</td> </tr> <tr> <td><code>BADCAB1E</code></td> <td>Error Code returned to the Microsoft eVC debugger when connection is severed to the debugger</td> </tr> <tr> <td><code>BADDCAFE</code></td> <td>On <a href="/wiki/Sun_Microsystems">Sun Microsystems</a>' <a href="/wiki/Solaris_%28operating_system%29" title="Solaris (operating system)">Solaris</a>, marks uninitialised kernel memory (KMEM_UNINITIALIZED_PATTERN)</td> </tr> <tr> <td><code>BEEFCACE</code></td> <td>Used by Microsoft .NET as a magic number in resource files</td> </tr> <tr> <td><code>C0DEDBAD</code></td> <td>A memory leak tracking tool which it will change the MMU tables so that all references to address zero</td> </tr> <tr> <td><code>CAFEBABE</code></td> <td>Used by both <a href="/wiki/Universal_binary" title="Universal binary">Universal</a> <a href="/wiki/Mach-O">Mach-O</a> binaries and <a href="/wiki/Java_%28programming_language%29" title="Java (programming language)">Java</a> .class files</td> </tr> <tr> <td><code>CAFEFEED</code></td> <td>Used by <a href="/wiki/Sun_Microsystems">Sun Microsystems</a>' <a href="/wiki/Solaris_%28operating_system%29" title="Solaris (operating system)">Solaris</a> debugging kernel to mark kmemfree() memory</td> </tr> <tr> <td><code>CCCCCCCC</code></td> <td>Used by <a href="/wiki/Microsoft">Microsoft</a>'s C++ debugging runtime library to mark uninitialised <a href="/wiki/Stack-based_memory_allocation" title="Stack-based memory allocation">stack</a> memory</td> </tr> <tr> <td><code>CDCDCDCD</code></td> <td>Used by <a href="/wiki/Microsoft">Microsoft</a>'s C++ debugging runtime library to mark uninitialised heap memory</td> </tr> <tr> <td><code>CEFAEDFE</code></td> <td>Seen in Intel <a href="/wiki/Mach-O">Mach-O</a> binaries on <a href="/wiki/Apple_Inc.">Apple Inc.</a>'s <a href="/wiki/Mac_OS_X">Mac OS X</a> platform (see <code>FEEDFACE</code>)</td> </tr> <tr> <td><code>DDDDDDDD</code></td> <td>Used by MicroQuill's SmartHeap and Microsoft's C++ debugging heap to mark freed heap memory</td> </tr> <tr> <td><code>DEADBABE</code></td> <td>Used at the start of <a href="/wiki/Silicon_Graphics">Silicon Graphics</a>' <a href="/wiki/IRIX">IRIX</a> arena files</td> </tr> <tr> <td><code>DEADBEEF</code></td> <td>Famously used on <a href="/wiki/IBM">IBM</a> systems such as the <a href="/wiki/RS/6000">RS/6000</a>, also used in the original <a href="/wiki/Mac_OS">Mac OS</a> <a href="/wiki/Operating_system" title="Operating system">operating systems</a>, <a href="/wiki/OPENSTEP_Enterprise" class="mw-redirect" title="OPENSTEP Enterprise">OPENSTEP Enterprise</a>, and the <a href="/wiki/Commodore_International" title="Commodore International">Commodore</a> <a href="/wiki/Amiga">Amiga</a>. On <a href="/wiki/Sun_Microsystems">Sun Microsystems</a>' <a href="/wiki/Solaris_%28operating_system%29" title="Solaris (operating system)">Solaris</a>, marks freed kernel memory (KMEM_FREE_PATTERN)</td> </tr> <tr> <td><code>DEADDEAD</code></td> <td>A <a href="/wiki/Microsoft">Microsoft</a> Windows STOP Error code used when the user manually initiates the crash.</td> </tr> <tr> <td><code>DEADF00D</code></td> <td>Used by Mungwall on the <a href="/wiki/Commodore_International" title="Commodore International">Commodore</a> <a href="/wiki/Amiga">Amiga</a> to mark allocated but uninitialised memory <sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span>[</span>12<span>]</span></a></sup></td> </tr> <tr> <td><code>DEADFA11</code></td> <td>Used by <a href="/wiki/Apple_Inc." title="Apple Inc.">Apple</a> as the exception code in <a href="/wiki/IPhone">iPhone</a> crash reports when the user has force-quit the application.</td> </tr> <tr> <td><code>EBEBEBEB</code></td> <td>From MicroQuill's SmartHeap</td> </tr> <tr> <td><code>FADEDEAD</code></td> <td>Comes at the end to identify every <a href="/wiki/AppleScript">AppleScript</a> script</td> </tr> <tr> <td><code>FDFDFDFD</code></td> <td>Used by <a href="/wiki/Microsoft">Microsoft</a>'s C++ debugging heap to mark "no man's land" <a href="/wiki/Guard_byte" title="Guard byte">guard bytes</a> before and after allocated heap memory</td> </tr> <tr> <td><code>FEE1DEAD</code></td> <td>Used by <a href="/wiki/Linux">Linux</a> reboot() syscall</td> </tr> <tr> <td><code>FEEDFACE</code></td> <td>Seen in PowerPC <a href="/wiki/Mach-O">Mach-O</a> binaries on <a href="/wiki/Apple_Inc.">Apple Inc.</a>'s <a href="/wiki/Mac_OS_X">Mac OS X</a> platform. On <a href="/wiki/Sun_Microsystems">Sun Microsystems</a>' <a href="/wiki/Solaris_%28operating_system%29" title="Solaris (operating system)">Solaris</a>, marks the red zone (KMEM_REDZONE_PATTERN)</td> </tr> <tr> <td><code>FEEEFEEE</code></td> <td>Used by <a href="/wiki/Microsoft">Microsoft</a>'s HeapFree() to mark freed heap memory</td> </tr> </tbody></table> <p>Note that most of these are each 32 <a href="/wiki/Bit" title="Bit">bits</a> long &#x2014; the <a href="/wiki/Word_size" title="Word size" class="mw-redirect">dword size</a> of 32-bit architecture computers.</p> <p>The prevalence of these values in Microsoft technology is no coincidence; they are discussed in detail in <a href="/wiki/Steve_Maguire">Steve Maguire</a>'s book <i><a href="/w/index.php?title=Writing_Solid_Code&amp;action=edit&amp;redlink=1" class="new" title="Writing Solid Code (page does not exist)">Writing Solid Code</a></i> from <a href="/wiki/Microsoft_Press">Microsoft Press</a>. He gives a variety of criteria for these values, such as:</p> <ul> <li>They should not be useful; that is, most algorithms that operate on them should be expected to do something unusual. Numbers like zero don't fit this criterion.</li> <li>They should be easily recognized by the programmer as invalid values in the debugger.</li> <li>On machines that don't have <a href="/wiki/Byte_alignment" class="mw-redirect" title="Byte alignment">byte alignment</a>, they should be <a href="/wiki/Odd_number" title="Odd number" class="mw-redirect">odd numbers</a>, so that dereferencing them as addresses causes an exception.</li> <li>They should cause an exception, or perhaps even a debugger break, if executed as code.</li> </ul> <p>Since they were often used to mark areas of memory that were essentially empty, some of these terms came to be used in phrases meaning "gone, aborted, flushed from memory"; e.g. "Your program is DEADBEEF".</p> <p><a href="/w/index.php?title=Pietr_Brandeh%C3%B6rst&amp;action=edit&amp;redlink=1" class="new" title="Pietr Brandeh&#xf6;rst (page does not exist)">Pietr Brandeh&#xf6;rst</a>'s <a href="/w/index.php?title=ZUG_programming_language&amp;action=edit&amp;redlink=1" class="new" title="ZUG programming language (page does not exist)">ZUG programming language</a> initialized memory to either <code>0000</code>, <code>DEAD</code> or <code>FFFF</code> in development environment and to <code>0000</code> in the live environment, on the basis that uninitialised variables should be encouraged to misbehave under development to trap them, but encouraged to behave in a live environment to reduce errors<sup class="Template-Fact" title="This claim needs references to reliable sources from April 2008" style="white-space: nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed">citation needed</a></i>]</sup>.</p>