<div dir="ltr">Fix is in <a href="https://reviews.llvm.org/D77627">https://reviews.llvm.org/D77627</a><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 6, 2020 at 5:57 PM Sam Clegg <<a href="mailto:sbc@google.com">sbc@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I found the bug that is causing this:<div><br></div><div><a href="https://bugs.llvm.org/show_bug.cgi?id=45452" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=45452</a><br></div><div><br></div><div>Seems like it was always there but hidden by the fact that our test cases all use short string that don't require a std::string to allocate.</div><div><br></div><div>Is it best to revert this (given that it doesn't actually introduce a new bug) right now ? Or can it wait a for a fix?</div><div><br></div><div>cheers,</div><div>sam</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 6, 2020 at 3:09 PM Matt Morehouse <<a href="mailto:mascasa@google.com" target="_blank">mascasa@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Also hitting this on our sanitizer bots: <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/40166/steps/check-llvm%20asan/logs/stdio" target="_blank">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/40166/steps/check-llvm%20asan/logs/stdio</a><div><br></div><div><pre style="font-family:"Courier New",courier,monotype,monospace;color:rgb(0,0,0);font-size:medium"><span>FAIL: LLVM :: CodeGen/WebAssembly/lower-em-ehsjlj-options.ll (17638 of 36878)
******************** TEST 'LLVM :: CodeGen/WebAssembly/lower-em-ehsjlj-options.ll' FAILED ********************
Script:
--
: 'RUN: at line 1'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/llc < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll -enable-emscripten-cxx-exceptions | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/WebAssembly/low</span><span>er-em-ehsjlj-options.ll --check-prefix=EH
</span><span>: 'RUN: at line 2'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/llc < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll -enable-emscripten-sjlj | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll --check-prefix=SJLJ
: 'RUN: at line 3'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/llc < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll --check-prefix=NONE
--
Exit Code: 1
Command Output (stderr):
--
=================================================================
==46181==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x97b4fd in operator new(unsigned long) /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/asan/asan_new_delete.cpp:99:3
#1 0xdd0b52 in __libcpp_allocate /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/new:253:10
#2 0xdd0b52 in allocate /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:1900:34
#3 0xdd0b52 in allocate /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:1591:21
#4 0xdd0b52 in __init /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/string:1822:15
#5 0xdd0b52 in basic_string /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/string:1849:5
#6 0xdd0b52 in str /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/StringRef.h:250:14
#7 0xdd0b52 in operator basic_string /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/StringRef.h:275:52
#8 0xdd0b52 in llvm::MCSymbolWasm::setImportName(llvm::StringRef) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/MC/MCSymbolWasm.h:95:42
#9 0x2d0d944 in llvm::WebAssemblyAsmPrinter::emitEndOfAsmFile(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:132:14
#10 0x409bdcf in llvm::AsmPrinter::doFinalization(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1715:3
#11 0x523942d in llvm::FPPassManager::doFinalization(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1536:41
#12 0x523a2b0 in runOnModule /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1612:41
#13 0x523a2b0 in llvm::legacy::PassManagerImpl::run(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1695:44
#14 0x984bba in compileModule(char**, llvm::LLVMContext&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llc/llc.cpp:624:8
#15 0x97fb1f in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llc/llc.cpp:360:22
#16 0x7f6e152b02e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).
</span></pre><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 4, 2020 at 2:05 AM Mikael Holmén via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Fri, 2020-04-03 at 13:10 -0700, Sam Clegg wrote:<br>
> Its hard to see how this change could have triggered a leak. Are you<br>
> sure it was this commit?<br>
<br>
Yes I reran before your commit without complaints and then with<br>
296ccef703 this started happening.<br>
<br>
> If you are, I can try to make lsan build locally and reproduce. I<br>
> don't suppose you are able to symbolize that backtrace can you?<br>
<br>
Here:<br>
<br>
=================================================================<br>
==23829==ERROR: LeakSanitizer: detected memory leaks<br>
<br>
Direct leak of 32 byte(s) in 1 object(s) allocated from:<br>
#0 0x987410 in operator new(unsigned long)<br>
(/local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-<br>
sanitize-asan/llvm/build-sana/bin/llc+0x987410)<br>
#1 0xe08c09 in __allocate /usr/include/c++/v1/new:228:10<br>
#2 0xe08c09 in allocate /usr/include/c++/v1/memory:1793<br>
#3 0xe08c09 in allocate /usr/include/c++/v1/memory:1547<br>
#4 0xe08c09 in __init /usr/include/c++/v1/string:1591<br>
#5 0xe08c09 in basic_string /usr/include/c++/v1/string:1628<br>
#6 0xe08c09 in str /local/repo/bbiswjenk/fem023-<br>
eiffel003/workspace/llvm/llvm-master-sanitize-asan/llvm/build-<br>
sana/../include/llvm/ADT/StringRef.h:250<br>
#7 0xe08c09 in operator basic_string /local/repo/bbiswjenk/fem023-<br>
eiffel003/workspace/llvm/llvm-master-sanitize-asan/llvm/build-<br>
sana/../include/llvm/ADT/StringRef.h:275<br>
#8 0xe08c09 in llvm::MCSymbolWasm::setImportName(llvm::StringRef)<br>
/local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-<br>
sanitize-asan/llvm/build-sana/../include/llvm/MC/MCSymbolWasm.h:95<br>
#9 0x2daf3b2 in<br>
llvm::WebAssemblyAsmPrinter::emitEndOfAsmFile(llvm::Module&)<br>
/local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-<br>
sanitize-asan/llvm/build-<br>
sana/../lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:132:14<br>
#10 0x41bf04a in llvm::AsmPrinter::doFinalization(llvm::Module&)<br>
/local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-<br>
sanitize-asan/llvm/build-<br>
sana/../lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1715:3<br>
#11 0x53969fd in llvm::FPPassManager::doFinalization(llvm::Module&)<br>
/local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-<br>
sanitize-asan/llvm/build-sana/../lib/IR/LegacyPassManager.cpp:1536:41<br>
#12 0x5397890 in runOnModule /local/repo/bbiswjenk/fem023-<br>
eiffel003/workspace/llvm/llvm-master-sanitize-asan/llvm/build-<br>
sana/../lib/IR/LegacyPassManager.cpp:1612:41<br>
#13 0x5397890 in llvm::legacy::PassManagerImpl::run(llvm::Module&)<br>
/local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-<br>
sanitize-asan/llvm/build-sana/../lib/IR/LegacyPassManager.cpp:1695<br>
#14 0x992e79 in compileModule(char**, llvm::LLVMContext&)<br>
/local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-<br>
sanitize-asan/llvm/build-sana/../tools/llc/llc.cpp:624:8<br>
#15 0x98d490 in main /local/repo/bbiswjenk/fem023-<br>
eiffel003/workspace/llvm/llvm-master-sanitize-asan/llvm/build-<br>
sana/../tools/llc/llc.cpp:360:22<br>
#16 0x7ff9852e7b96 in __libc_start_main /build/glibc-OTsEL5/glibc-<br>
2.27/csu/../csu/libc-start.c:310<br>
<br>
SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).<br>
<br>
/Mikael<br>
<br>
> <br>
> On Fri, Apr 3, 2020 at 2:49 AM Mikael Holmén <<br>
> <a href="mailto:mikael.holmen@ericsson.com" target="_blank">mikael.holmen@ericsson.com</a>> wrote:<br>
> > Hi,<br>
> > <br>
> > I noticed on one of my organization's build bots that runs with<br>
> > sanatizers that we got a warning about a leak with this commit. So<br>
> > when<br>
> > running the testcase<br>
> > test/CodeGen/WebAssembly/irreducible-cfg-exceptions.ll<br>
> > <br>
> > build-sana/bin/llc < test/CodeGen/WebAssembly/irreducible-cfg-<br>
> > exceptions.ll -asm-verbose=false -verify-machineinstrs -disable-<br>
> > block-<br>
> > placement -wasm-disable-explicit-locals -wasm-keep-registers<br>
> > -enable-<br>
> > emscripten-cxx-exceptions | build-sana/bin/FileCheck<br>
> > test/CodeGen/WebAssembly/irreducible-cfg-exceptions.ll<br>
> > <br>
> > I get<br>
> > <br>
> > =================================================================<br>
> > ==5081==ERROR: LeakSanitizer: detected memory leaks<br>
> > <br>
> > Direct leak of 32 byte(s) in 1 object(s) allocated from:<br>
> > #0 0x421d520 (/data/repo/master/llvm/build-<br>
> > sana/bin/llc+0x421d520)<br>
> > #1 0x46a9ec9 (/data/repo/master/llvm/build-<br>
> > sana/bin/llc+0x46a9ec9)<br>
> > #2 0x676cc32 (/data/repo/master/llvm/build-<br>
> > sana/bin/llc+0x676cc32)<br>
> > #3 0x7bbf0ca (/data/repo/master/llvm/build-<br>
> > sana/bin/llc+0x7bbf0ca)<br>
> > #4 0x8e2374d (/data/repo/master/llvm/build-<br>
> > sana/bin/llc+0x8e2374d)<br>
> > #5 0x8e245e0 (/data/repo/master/llvm/build-<br>
> > sana/bin/llc+0x8e245e0)<br>
> > #6 0x4228f89 (/data/repo/master/llvm/build-<br>
> > sana/bin/llc+0x4228f89)<br>
> > #7 0x42235a0 (/data/repo/master/llvm/build-<br>
> > sana/bin/llc+0x42235a0)<br>
> > #8 0x7f50ee2f4b96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)<br>
> > <br>
> > SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).<br>
> > <br>
> > /Mikael<br>
> > <br>
> > On Wed, 2020-04-01 at 16:33 -0700, Sam Clegg via llvm-commits<br>
> > wrote:<br>
> > > Author: Sam Clegg<br>
> > > Date: 2020-04-01T16:33:33-07:00<br>
> > > New Revision: 296ccef70363df9195bc678ad5501dd44de7f8fb<br>
> > > <br>
> > > URL: <br>
> > > <br>
> > <a href="https://protect2.fireeye.com/v1/url?k=6f7ff692-33f65951-6f7fb609-0cc47ad93d36-d092eb1748b9557d&q=1&e=1ca40782-7747-4f20-89e4-55dbb09d830d&u=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fcommit%2F296ccef70363df9195bc678ad5501dd44de7f8fb" rel="noreferrer" target="_blank">https://protect2.fireeye.com/v1/url?k=6f7ff692-33f65951-6f7fb609-0cc47ad93d36-d092eb1748b9557d&q=1&e=1ca40782-7747-4f20-89e4-55dbb09d830d&u=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fcommit%2F296ccef70363df9195bc678ad5501dd44de7f8fb</a><br>
> > > DIFF: <br>
> > > <br>
> > <a href="https://protect2.fireeye.com/v1/url?k=4a3efd3f-16b752fc-4a3ebda4-0cc47ad93d36-ac161843750d844e&q=1&e=1ca40782-7747-4f20-89e4-55dbb09d830d&u=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fcommit%2F296ccef70363df9195bc678ad5501dd44de7f8fb.diff" rel="noreferrer" target="_blank">https://protect2.fireeye.com/v1/url?k=4a3efd3f-16b752fc-4a3ebda4-0cc47ad93d36-ac161843750d844e&q=1&e=1ca40782-7747-4f20-89e4-55dbb09d830d&u=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fcommit%2F296ccef70363df9195bc678ad5501dd44de7f8fb.diff</a><br>
> > > <br>
> > > LOG: [WebAssembly] EmscriptenEHSjLj: Mark __invoke_ functions as<br>
> > > imported<br>
> > > <br>
> > > This means the linker will be expect them be undefined at link<br>
> > time<br>
> > > an<br>
> > > will generate imports from the `env` module rather than reporting<br>
> > > undefined externals.<br>
> > > <br>
> > > Differential Revision: <a href="https://reviews.llvm.org/D77192" rel="noreferrer" target="_blank">https://reviews.llvm.org/D77192</a><br>
> > > <br>
> > > Added: <br>
> > > <br>
> > > <br>
> > > Modified: <br>
> > > <br>
> > llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp<br>
> > > llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll<br>
> > > <br>
> > > Removed: <br>
> > > <br>
> > > <br>
> > > <br>
> > ><br>
> > ###################################################################<br>
> > ##<br>
> > > ###########<br>
> > > diff --git<br>
> > ><br>
> > a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp<br>
> > ><br>
> > b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp<br>
> > > index 89265a3a9520..c8878a48b243 100644<br>
> > > ---<br>
> > ><br>
> > a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp<br>
> > > +++<br>
> > ><br>
> > b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp<br>
> > > @@ -344,6 +344,21 @@ static std::string getSignature(FunctionType<br>
> > > *FTy) {<br>
> > > return Sig;<br>
> > > }<br>
> > > <br>
> > > +static void markAsImported(Function *F) {<br>
> > > + // Tell the linker that this function is expected to be<br>
> > imported<br>
> > > from the<br>
> > > + // 'env' module.<br>
> > > + if (!F->hasFnAttribute("wasm-import-module")) {<br>
> > > + llvm::AttrBuilder B;<br>
> > > + B.addAttribute("wasm-import-module", "env");<br>
> > > + F->addAttributes(llvm::AttributeList::FunctionIndex, B);<br>
> > > + }<br>
> > > + if (!F->hasFnAttribute("wasm-import-name")) {<br>
> > > + llvm::AttrBuilder B;<br>
> > > + B.addAttribute("wasm-import-name", F->getName());<br>
> > > + F->addAttributes(llvm::AttributeList::FunctionIndex, B);<br>
> > > + }<br>
> > > +}<br>
> > > +<br>
> > > // Returns __cxa_find_matching_catch_N function, where N =<br>
> > > NumClauses + 2.<br>
> > > // This is because a landingpad instruction contains two more<br>
> > > arguments, a<br>
> > > // personality function and a cleanup bit, and<br>
> > > __cxa_find_matching_catch_N<br>
> > > @@ -360,6 +375,7 @@<br>
> > > WebAssemblyLowerEmscriptenEHSjLj::getFindMatchingCatch(Module &M,<br>
> > > Function *F = Function::Create(<br>
> > > FTy, GlobalValue::ExternalLinkage,<br>
> > > "__cxa_find_matching_catch_" + Twine(NumClauses + 2), &M);<br>
> > > + markAsImported(F);<br>
> > > FindMatchingCatches[NumClauses] = F;<br>
> > > return F;<br>
> > > }<br>
> > > @@ -469,6 +485,7 @@ Function<br>
> > > *WebAssemblyLowerEmscriptenEHSjLj::getInvokeWrapper(CallOrInvoke<br>
> > *CI)<br>
> > > {<br>
> > > CalleeFTy->isVarArg());<br>
> > > Function *F =<br>
> > > Function::Create(FTy, GlobalValue::ExternalLinkage,<br>
> > > "__invoke_" + Sig, M);<br>
> > > + markAsImported(F);<br>
> > > InvokeWrappers[Sig] = F;<br>
> > > return F;<br>
> > > }<br>
> > > <br>
> > > diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll<br>
> > > b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll<br>
> > > index cad6c4ac855b..ad42cc5f8615 100644<br>
> > > --- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll<br>
> > > +++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll<br>
> > > @@ -308,6 +308,10 @@ attributes #0 = { returns_twice }<br>
> > > attributes #1 = { noreturn }<br>
> > > attributes #2 = { nounwind }<br>
> > > attributes #3 = { allocsize(0) }<br>
> > > +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"<br>
> > > "wasm-import-name"="__invoke_void" }<br>
> > > +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"<br>
> > > "wasm-import-name"="__cxa_find_matching_catch_3" }<br>
> > > +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"<br>
> > > "wasm-import-name"="__invoke_i8*_i32_%struct.__jmp_buf_tag*" }<br>
> > > +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"<br>
> > > "wasm-import-name"="__invoke_void_%struct.__jmp_buf_tag*_i32" }<br>
> > > ; CHECK: attributes #[[ALLOCSIZE_ATTR]] = { allocsize(1) }<br>
> > > <br>
> > > !<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!2}<br>
> > > <br>
> > > <br>
> > > <br>
> > > _______________________________________________<br>
> > > llvm-commits mailing list<br>
> > > <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> > > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>