<html>
    <head>
      <base href="https://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 --- - Program crashes when throwing exception under memory sanitizer."
   href="https://llvm.org/bugs/show_bug.cgi?id=31877">31877</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Program crashes when throwing exception under memory sanitizer.
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>4.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>halyavin@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>kcc@google.com, llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following program crashes with memory sanitizer.

test.cpp:

#include <stdio.h>
#include <exception>

// Poison parameters shadow.
__attribute__ ((noinline)) void func(int, int, int, int, int, int) {
    try {
        throw std::exception();
    } catch (std::exception& e) {
        printf("here\n");
    }
}

int main() {
    int a, b, c, d, e, f;
    func(a, b, c, d, e, f);
}

Compilation:
1. Compile and copy memory-sanitized libc++.so and libc++abi.so to the same
folder as test.cpp.
2. clang++ test.cpp -o test -stdlib=libc++ -L. -Wl,-rpath=. -fsanitize=memory

Output:
./test
==3802==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f51243b3313 in get_thrown_object_ptr
/home/halyavin/other/llvm/projects/libcxxabi/src/cxa_personality.cpp:490:27
    #1 0x7f51243b3313 in __cxxabiv1::scan_eh_tab(__cxxabiv1::(anonymous
namespace)::scan_results&, _Unwind_Action, bool, _Unwind_Exception*,
_Unwind_Context*)
/home/halyavin/other/llvm/projects/libcxxabi/src/cxa_personality.cpp:736
    #2 0x7f51243b14e5 in __gxx_personality_v0
/home/halyavin/other/llvm/projects/libcxxabi/src/cxa_personality.cpp:951:9
    #3 0x7f5124995262  (/lib/x86_64-linux-gnu/libgcc_s.so.1+0x10262)
    #4 0x7f51243aff6d in __cxa_throw
/home/halyavin/other/llvm/projects/libcxxabi/src/cxa_exception.cpp:238:5
    #5 0x489534 in func(int, int, int, int, int, int)
(/home/halyavin/other/msan-exceptions/test+0x489534)
    #6 0x4897f4 in main (/home/halyavin/other/msan-exceptions/test+0x4897f4)
    #7 0x7f51245dc82f  (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #8 0x419c88 in _start (/home/halyavin/other/msan-exceptions/test+0x419c88)

The problem is that libgcc_s.so is not memory sanitized and so it does not
update parameters shadow before calling __gxx_personality_v0 function.</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>