<div dir="ltr">I should have a fix soon.<div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 10, 2015 at 8:10 AM, Diego Novillo <span dir="ltr"><<a href="mailto:dnovillo@google.com" target="_blank">dnovillo@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 9, 2015 at 7:24 PM, Xinliang David Li via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+std::unique_ptr<ValueProfData><br>
+ValueProfData::serializeFrom(const InstrProfRecord &Record) {<br>
+  uint32_t TotalSize = getSize(Record);<br>
+  std::unique_ptr<ValueProfData> VPD(<br>
+      reinterpret_cast<ValueProfData *>(new char[TotalSize]));<br></blockquote><div><br></div><div>David, this is causing ASan failures on the LLVM testsuite.  Specifically, this allocation via new[] is then deallocated with just delete by the runtime std::unique_ptr support.  So, ASan complains with:</div><div><br></div><div> <span style="color:rgb(0,0,0);line-height:18.592px;white-space:pre-wrap">ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x60200000ee90</span></div><pre style="margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);line-height:18.592px">    #0 0x4de26b in operator delete(void*) llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:94:3
    #1 0x7dfaf0 in std::unique_ptr<llvm::IndexedInstrProf::ValueProfData, std::default_delete<llvm::IndexedInstrProf::ValueProfData> >::~unique_ptr() [...]/bits/unique_ptr.h:236:4
    #2 0x7fd8c6 in (anonymous namespace)::InstrProfRecordTrait::EmitData(llvm::raw_ostream&, llvm::StringRef, llvm::SmallDenseMap<unsigned long, llvm::InstrProfRecord, 1u, llvm::DenseMapInfo<unsigned long>, llvm::detail::DenseMapPair<unsigned long, llvm::InstrProfRecord> > const*, unsigned long) llvm/lib/ProfileData/InstrProfWriter.cpp:85:5

0x60200000ee90 is located 0 bytes inside of 8-byte region [0x60200000ee90,0x60200000ee98)
allocated by thread T0 here:
    #0 0x4dde1b in operator new[](unsigned long) llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:64:37
    #1 0x7de5e1 in llvm::IndexedInstrProf::ValueProfData::serializeFrom(llvm::InstrProfRecord const&) llvm/lib/ProfileData/InstrProf.cpp:251:41
    #2 0x7fd883 in (anonymous namespace)::InstrProfRecordTrait::EmitData(llvm::raw_ostream&, llvm::StringRef, llvm::SmallDenseMap<unsigned long, llvm::InstrProfRecord, 1u, llvm::DenseMapInfo<unsigned long>, llvm::detail::DenseMapPair<unsigned long, llvm::InstrProfRecord> > const*, unsigned long) llvm/lib/ProfileData/InstrProfWriter.cpp:81:11</pre><pre style="margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);line-height:18.592px"><br></pre><pre style="margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);line-height:18.592px"><br></pre>Not quite sure what the right fix for this usage pattern is wrt std::unique_ptr.  Mind if I revert the patch while you find a fix?</div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">Thanks.  Diego.</div></div></div>
</blockquote></div><br></div>