<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 --- - libunwind: fallback implementation of _dyld_find_unwind_sections fails to build for __LP64__ and crashes during exception throwing"
   href="http://llvm.org/bugs/show_bug.cgi?id=22270">22270</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>libunwind: fallback implementation of _dyld_find_unwind_sections fails to build for __LP64__ and crashes during exception throwing
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++abi
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jeremyhu@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13710" name="attach_13710" title="test_throw.cxx">attachment 13710</a> <a href="attachment.cgi?id=13710&action=edit" title="test_throw.cxx">[details]</a></span>
test_throw.cxx

A simple exception throw in C++ will cause a crash on Leopard.  Similar results
are observed if building libunwind.dylib on Syrah and forcing it to use the
fallback implementation of _dyld_find_unwind_sections.

$ git clone <a href="https://github.com/jeremyhu/libcxxabi.git">https://github.com/jeremyhu/libcxxabi.git</a>
$ cd libcxxabi/src/Unwind
$ git checkout debug-dyld_find_unwind_sections
$ make LIBDIR=/usr/lib/system LIBUNWIND_FILENAME=libunwind.dylib CFLAGS="-g3
-O0" CXXFLAGS="-g3 -O0"
...

$ clang++ -arch x86_64 test_throw.cxx -o test_throw.x86_64
$ DYLD_LIBRARY_PATH=. ./test_throw.x86_64
Segmentation fault: 11

$ clang++ -arch i386 test_throw.cxx -o test_throw.i386
$ DYLD_LIBRARY_PATH=. ./test_throw.i386
Segmentation fault: 11

---

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libmacho.dylib                    0x9335236c getsectiondata + 49
1   libunwind.dylib                   0x000f4932
libunwind::_dyld_find_unwind_sections(void*, libunwind::dyld_unwind_sections*)
+ 114 (.AddressSpace.hpp:317)
2   libunwind.dylib                   0x000f5a4b
libunwind::LocalAddressSpace::findUnwindSections(unsigned int,
libunwind::UnwindInfoSections&) + 43 (.AddressSpace.hpp:337)
3   libunwind.dylib                   0x000f54b2
libunwind::UnwindCursor<libunwind::LocalAddressSpace,
libunwind::Registers_x86>::setInfoBasedOnIPRegister(bool) + 114
(.UnwindCursor.hpp:1158)
4   libunwind.dylib                   0x000f3ef0 unw_init_local + 176
(libunwind.cpp:63)
5   libunwind.dylib                   0x000f057d unwind_phase1 + 77
(UnwindLevel1.c:34)
6   libunwind.dylib                   0x000f04dd _Unwind_RaiseException + 157
(UnwindLevel1.c:343)
7   libc++abi.dylib                   0x98e794c8 __cxa_throw + 103
8   test_throw.i386                   0x000eae2a main + 90
9   libdyld.dylib                     0x90c546d9 start + 1</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>