<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hello!<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I'm a brand new clang user and this is my first time on the cfe-dev mailing list. I was wondering if anyone could tell me what I'm doing wrong.<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I'm running clang 4.0.0 asan built on Linux x86_64. I built my code using <span>clang++</span> <span>-fsanitize=address</span>.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I can't suppress the following memory issue reported by asan outside my code: (I have abridged the stack trace and modified some filepaths)<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>==104630==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200019367c at pc 0x2aaaaadc0d85 bp 0x7fffffff7e90 sp 0x7fffffff7640<br>
READ of size 16 at 0x60200019367c thread T0<br>
    #0 0x2aaaaadc0d84 in __asan_memcpy /path/to/llvm-4.0.0.src/projects/compiler-rt/lib/asan/asan_interceptors.cc:453<br>
    #1 0x5b74a8 in _ZNSt3__116allocator_traitsINS_9allocatorIiEEE20__construct_backwardIiEENS_9enable_ifIXaaoosr7is_sameIS2_NS1_IT_EEEE5valuentsr15__has_constructIS2_PS6_S6_EE5valuesr31is_trivially_move_constructibleIS6_EE5valueEvE4typeERS2_S8_S8_RS8_ /path/to/clang/clang-4.0.0/rawbin/../include/c++/v1/memory:1676:17<br>
    #2 0x5b74a8 in std::__1::vector<int, std::__1::allocator<int> >::__swap_out_circular_buffer(std::__1::__split_buffer<int, std::__1::allocator<int>&>&) /path/to/clang/clang-4.0.0/rawbin/../include/c++/v1/vector:886<br>
    #3 0x5b648a in void std::__1::vector<int, std::__1::allocator<int> >::__push_back_slow_path<int const&>(int const&) /path/to/clang/clang-4.0.0/rawbin/../include/c++/v1/vector:1574:5<br>
    #4 0x1d8d2ba in std::__1::vector<int, std::__1::allocator<int> >::push_back(int const&) /path/to/clang/clang-4.0.0/rawbin/../include/c++/v1/vector:1591:9<br>
    #5 0x1d8d2ba in bar::baz(a_type const*, int const*, std::__1::vector<int, std::__1::allocator<int> >&) /path/to/installed/3rd/party/library/that/i/did/not/build/foo.cc:394</div>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0">I am following the instructions here <a href="http://releases.llvm.org/4.0.0/tools/clang/docs/AddressSanitizer.html#issue-suppression" class="OWAAutoLink" id="LPlnk896463" previewremoved="true">
http://releases.llvm.org/4.0.0/tools/clang/docs/AddressSanitizer.html#issue-suppression</a> , and I verified that my .supp is being read by typing gibberish in it and seeing "<span>AddressSanitizer: failed to parse suppressions</span>" printed to my terminal.
 I took a look at the src for __asan_memcpy in compiler-rt-4.0.0.src/<span>lib/asan/asan_interceptors.cc</span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>452 void *__asan_memcpy(void *to, const void *from, uptr size) {<br>
453   ASAN_MEMCPY_IMPL(nullptr, to, from, size);<br>
454 }</div>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I think the "nullptr" is my problem. I followed the macro trail to find these lines</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span> 68       AsanInterceptorContext *_ctx = (AsanInterceptorContext *)ctx;     \</span><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div> 69       bool suppressed = false;                                          \<br>
 70       if (_ctx) {                                                       \<br>
 71         suppressed = IsInterceptorSuppressed(_ctx->interceptor_name);   \<br>
 72         if (!suppressed && HaveStackTraceBasedSuppressions()) {         \<br>
 73           GET_STACK_TRACE_FATAL_HERE;                                   \<br>
 74           suppressed = IsStackTraceSuppressed(&stack);                  \<br>
 75         }                                                               \<br>
 76       }                                                                 \<br>
 77       if (!suppressed) {                                                \<br>
 78         GET_CURRENT_PC_BP_SP;                                           \<br>
 79         ReportGenericError(pc, bp, sp, __bad, isWrite, __size, 0, false);\<br>
 80       } </div>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Since ctx is always "nullptr", "if (_ctx)" always evaluates to false, meaning I will not be able to suppress my memory error. Is this by design, or by mistake?<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">A quick look at the latest compiler-rt src that I pulled down today (git hash
<span>286b899df64bb82a2da253114653adaf15da2fce</span>, <span>git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@323510 91177308-0d34-0410-b5e6-96231b3b80d8</span>) shows the same situation exists for the latest asan implementation, so I don't think
 that updating to the latest asan rtl will help.<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div id="Signature">
<div style="font-family:Tahoma; font-size:13px">Mike Pozulp<br>
pozulp1@llnl.gov<br>
925-422-0653<br>
</div>
</div>
</div>
</body>
</html>