<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 --- - MemorySanitizer false positive in module destructors"
   href="http://llvm.org/bugs/show_bug.cgi?id=17377">17377</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MemorySanitizer false positive in module destructors
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </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>compiler-rt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>eugeni.stepanov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ cat 1.cc
#include <stdio.h>
#include <stdlib.h>
class A {
public:
    ~A() {
        if (this)
            exit(1);
    }
};

A a;

__attribute__((noinline))
void f(long x) {
}

int main(void) {
    long  x;
    long * volatile p = &x;
    f(*p);
    return 0;    
}

$ ./build/bin/clang++ -fsanitize=memory 1.cc -o 1 -O0 -g
$ MSAN_SYMBOLIZER_PATH=build/bin/llvm-symbolizer ./1
==19875== WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f5818982037 in A::~A() /code/llvm/1.cc:6
    #1 0x7f5818981fbd in A::~A() /code/llvm/1.cc:5
    #2 0x7f581754b900 in __run_exit_handlers
/build/buildd/eglibc-2.15/stdlib/exit.c:78
    #3 0x7f581754b984 in __GI_exit /build/buildd/eglibc-2.15/stdlib/exit.c:100
    #4 0x7f5817531773 in __libc_start_main
/build/buildd/eglibc-2.15/csu/libc-start.c:258
    #5 0x7f5818981cf0 in _start (/code/llvm/1+0x52cf0)

The cause is obvious: module destructors get stale argument shadow due to being
called from (uninstrumented) libc.</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>