<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Invalid compact unwind info generated for a function without frame pointers on OSX"
   href="http://llvm.org/bugs/show_bug.cgi?id=20800">20800</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid compact unwind info generated for a function without frame pointers on OSX
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>glider@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>isanbard@gmail.com, kcc@google.com, kledzik@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The attached file contains the __asan_report_error function for which the
compact unwind info appears to be incorrect if the frame pointers are omitted:

$ bin/clang++   -O3   -fomit-frame-pointer asan_report.ii -c
$ bin/llvm-objdump -unwind-info -d asan_report.o
...
__Z19__asan_report_errormmmm:
       0:       55                                              pushq   %rbp
       1:       41 57                                           pushq   %r15
       3:       41 56                                           pushq   %r14
       5:       41 55                                           pushq   %r13
       7:       41 54                                           pushq   %r12
       9:       53                                              pushq   %rbx
       a:       48 81 ec 18 08 00 00                            subq    $2072,
%rsp
...
Contents of __compact_unwind section:
  Entry at offset 0x0:
    start:                0x0 __Z19__asan_report_errormmmm
    length:               0xda
    compact encoding:     0x0309f800

According to /usr/include/mach-o/compact_unwind_encoding.h, the compact
encoding uses the frameless stack index mode (0x03000000 is
UNWIND_X86_64_MODE_STACK_IND), so the second byte of the compact encoding must
be the offset of the immediate constant denoting the stack size in the subq
instruction. This byte has value 0x9 instead of 0xc, which makes the unwinder
think the function stack size is around 3Gb.

This test case contains a reduced version of __asan_report_error in the ASan
runtime. I'm seeing actual crashes because of this bug when calling
_Unwind_Backtrace from the real __asan_report_error on OSX. GDB also has
problems unwinding through this function on OSX.
A number of other functions in the ASan runtime have the same incorrect compact
unwind info.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>