<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="using-stack-trace">
      </a>
      7.9.1.5 Using a Stack Trace
     </h4>
    </div>
   </div>
  </div>
  <p>
   On some operating systems, the error log contains a stack trace
        if
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   dies unexpectedly. You can use this
        to find out where (and maybe why)
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   died. See
   <a class="xref" href="error-log.html" title="7.4.2 The Error Log">
    Section 7.4.2, “The Error Log”
   </a>
   . To get a stack trace, you
        must not compile
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   with the
   <code class="option">
    -fomit-frame-pointer
   </code>
   option to gcc. See
   <a class="xref" href="compiling-for-debugging.html" title="7.9.1.1 Compiling MySQL for Debugging">
    Section 7.9.1.1, “Compiling MySQL for Debugging”
   </a>
   .
  </p>
  <p>
   A stack trace in the error log looks something like this:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa13954958"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">mysqld got signal 11<span class="token punctuation">;</span>
Attempting backtrace<span class="token punctuation">.</span> You can use the following information
to find out where mysqld died<span class="token punctuation">.</span> If you see no messages after
this<span class="token punctuation">,</span> something went terribly wrong<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

stack_bottom <span class="token operator">=</span> 0x41fd0110 thread_stack 0x40000
mysqld<span class="token punctuation">(</span>my_print_stacktrace<span class="token operator">+</span>0x32<span class="token punctuation">)</span><span class="token punctuation">[</span>0x9da402<span class="token punctuation">]</span>
mysqld<span class="token punctuation">(</span>handle_segfault<span class="token operator">+</span>0x28a<span class="token punctuation">)</span><span class="token punctuation">[</span>0x6648e9<span class="token punctuation">]</span>
<span class="token operator">/</span>lib<span class="token operator">/</span>libpthread<span class="token punctuation">.</span>so<span class="token punctuation">.</span>0<span class="token punctuation">[</span>0x7f1a5af000f0<span class="token punctuation">]</span>
<span class="token operator">/</span>lib<span class="token operator">/</span>libc<span class="token punctuation">.</span>so<span class="token punctuation">.</span>6<span class="token punctuation">(</span>strcmp<span class="token operator">+</span>0x2<span class="token punctuation">)</span><span class="token punctuation">[</span>0x7f1a5a10f0f2<span class="token punctuation">]</span>
mysqld<span class="token punctuation">(</span>_Z21check_change_passwordP3THDPKcS2_Pcj<span class="token operator">+</span>0x7c<span class="token punctuation">)</span><span class="token punctuation">[</span>0x7412cb<span class="token punctuation">]</span>
mysqld<span class="token punctuation">(</span>_ZN16set_var_password5checkEP3THD<span class="token operator">+</span>0xd0<span class="token punctuation">)</span><span class="token punctuation">[</span>0x688354<span class="token punctuation">]</span>
mysqld<span class="token punctuation">(</span>_Z17sql_set_variablesP3THDP4ListI12set_var_baseE<span class="token operator">+</span>0x68<span class="token punctuation">)</span><span class="token punctuation">[</span>0x688494<span class="token punctuation">]</span>
mysqld<span class="token punctuation">(</span>_Z21mysql_execute_commandP3THD<span class="token operator">+</span>0x41a0<span class="token punctuation">)</span><span class="token punctuation">[</span>0x67a170<span class="token punctuation">]</span>
mysqld<span class="token punctuation">(</span>_Z11mysql_parseP3THDPKcjPS2_<span class="token operator">+</span>0x282<span class="token punctuation">)</span><span class="token punctuation">[</span>0x67f0ad<span class="token punctuation">]</span>
mysqld<span class="token punctuation">(</span>_Z16dispatch_command19enum_server_commandP3THDPcj<span class="token operator">+</span>0xbb7<span class="token punctuation">[</span>0x67fdf8<span class="token punctuation">]</span>
mysqld<span class="token punctuation">(</span>_Z10do_commandP3THD<span class="token operator">+</span>0x24d<span class="token punctuation">)</span><span class="token punctuation">[</span>0x6811b6<span class="token punctuation">]</span>
mysqld<span class="token punctuation">(</span>handle_one_connection<span class="token operator">+</span>0x11c<span class="token punctuation">)</span><span class="token punctuation">[</span>0x66e05e<span class="token punctuation">]</span></code></pre>
  </div>
  <p>
   If resolution of function names for the trace fails, the trace
        contains less information:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa85368430"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">mysqld got signal 11<span class="token punctuation">;</span>
Attempting backtrace<span class="token punctuation">.</span> You can use the following information
to find out where mysqld died<span class="token punctuation">.</span> If you see no messages after
this<span class="token punctuation">,</span> something went terribly wrong<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

stack_bottom <span class="token operator">=</span> 0x41fd0110 thread_stack 0x40000
<span class="token punctuation">[</span>0x9da402<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x6648e9<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x7f1a5af000f0<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x7f1a5a10f0f2<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x7412cb<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x688354<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x688494<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x67a170<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x67f0ad<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x67fdf8<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x6811b6<span class="token punctuation">]</span>
<span class="token punctuation">[</span>0x66e05e<span class="token punctuation">]</span></code></pre>
  </div>
  <p>
   Newer versions of
   <code class="literal">
    glibc
   </code>
   stack trace functions
        also print the address as relative to the object. On
   <code class="literal">
    glibc
   </code>
   -based systems (Linux), the trace for an
        unexpected exit within a plugin looks something like:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa55397409"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">plugin<span class="token operator">/</span>auth<span class="token operator">/</span>auth_test_plugin<span class="token punctuation">.</span>so<span class="token punctuation">(</span><span class="token operator">+</span>0x9a6<span class="token punctuation">)</span><span class="token punctuation">[</span>0x7ff4d11c29a6<span class="token punctuation">]</span></code></pre>
  </div>
  <p>
   To translate the relative address (
   <code class="literal">
    +0x9a6
   </code>
   )
        into a file name and line number, use this command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa6089907"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">addr2line</span> <span class="token property">-fie</span> auth_test_plugin<span class="token punctuation">.</span>so 0x9a6
auth_test_plugin
mysql-trunk/plugin/auth/test_plugin<span class="token punctuation">.</span>c<span class="token punctuation">:</span>65</code></pre>
  </div>
  <p>
   The
   <span class="command">
    <strong>
     addr2line
    </strong>
   </span>
   utility is part of the
   <code class="literal">
    binutils
   </code>
   package on Linux.
  </p>
  <p>
   On Solaris, the procedure is similar. The Solaris
   <code class="literal">
    printstack()
   </code>
   already prints relative
        addresses:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa1765926"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">plugin<span class="token operator">/</span>auth<span class="token operator">/</span>auth_test_plugin<span class="token punctuation">.</span>so<span class="token operator">:</span>0x1510</code></pre>
  </div>
  <p>
   To translate, use this command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa72708234"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">gaddr2line</span> <span class="token property">-fie</span> auth_test_plugin<span class="token punctuation">.</span>so 0x1510
mysql-trunk/plugin/auth/test_plugin<span class="token punctuation">.</span>c<span class="token punctuation">:</span>88</code></pre>
  </div>
  <p>
   Windows already prints the address, function name and line:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa92360990"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">000007FEF07E10A4 auth_test_plugin<span class="token punctuation">.</span>dll<span class="token operator">!</span>auth_test_plugin<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">[</span>test_plugin<span class="token punctuation">.</span>c<span class="token operator">:</span>72<span class="token punctuation">]</span></code></pre>
  </div>
 </div>
 <br/>
</div>
