[llvm] 296ccef - [WebAssembly] EmscriptenEHSjLj: Mark __invoke_ functions as imported
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 20:49:35 PDT 2020
Fix is in https://reviews.llvm.org/D77627
On Mon, Apr 6, 2020 at 5:57 PM Sam Clegg <sbc at google.com> wrote:
> I found the bug that is causing this:
>
> https://bugs.llvm.org/show_bug.cgi?id=45452
>
> 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.
>
> 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?
>
> cheers,
> sam
>
> On Mon, Apr 6, 2020 at 3:09 PM Matt Morehouse <mascasa at google.com> wrote:
>
>> Also hitting this on our sanitizer bots:
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/40166/steps/check-llvm%20asan/logs/stdio
>>
>> 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/lower-em-ehsjlj-options.ll --check-prefix=EH: '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).
>>
>>
>>
>> On Sat, Apr 4, 2020 at 2:05 AM Mikael Holmén via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Hi,
>>>
>>> On Fri, 2020-04-03 at 13:10 -0700, Sam Clegg wrote:
>>> > Its hard to see how this change could have triggered a leak. Are you
>>> > sure it was this commit?
>>>
>>> Yes I reran before your commit without complaints and then with
>>> 296ccef703 this started happening.
>>>
>>> > If you are, I can try to make lsan build locally and reproduce. I
>>> > don't suppose you are able to symbolize that backtrace can you?
>>>
>>> Here:
>>>
>>> =================================================================
>>> ==23829==ERROR: LeakSanitizer: detected memory leaks
>>>
>>> Direct leak of 32 byte(s) in 1 object(s) allocated from:
>>> #0 0x987410 in operator new(unsigned long)
>>> (/local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-
>>> sanitize-asan/llvm/build-sana/bin/llc+0x987410)
>>> #1 0xe08c09 in __allocate /usr/include/c++/v1/new:228:10
>>> #2 0xe08c09 in allocate /usr/include/c++/v1/memory:1793
>>> #3 0xe08c09 in allocate /usr/include/c++/v1/memory:1547
>>> #4 0xe08c09 in __init /usr/include/c++/v1/string:1591
>>> #5 0xe08c09 in basic_string /usr/include/c++/v1/string:1628
>>> #6 0xe08c09 in str /local/repo/bbiswjenk/fem023-
>>> eiffel003/workspace/llvm/llvm-master-sanitize-asan/llvm/build-
>>> sana/../include/llvm/ADT/StringRef.h:250
>>> #7 0xe08c09 in operator basic_string /local/repo/bbiswjenk/fem023-
>>> eiffel003/workspace/llvm/llvm-master-sanitize-asan/llvm/build-
>>> sana/../include/llvm/ADT/StringRef.h:275
>>> #8 0xe08c09 in llvm::MCSymbolWasm::setImportName(llvm::StringRef)
>>> /local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-
>>> sanitize-asan/llvm/build-sana/../include/llvm/MC/MCSymbolWasm.h:95
>>> #9 0x2daf3b2 in
>>> llvm::WebAssemblyAsmPrinter::emitEndOfAsmFile(llvm::Module&)
>>> /local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-
>>> sanitize-asan/llvm/build-
>>> sana/../lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:132:14
>>> #10 0x41bf04a in llvm::AsmPrinter::doFinalization(llvm::Module&)
>>> /local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-
>>> sanitize-asan/llvm/build-
>>> sana/../lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1715:3
>>> #11 0x53969fd in llvm::FPPassManager::doFinalization(llvm::Module&)
>>> /local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-
>>> sanitize-asan/llvm/build-sana/../lib/IR/LegacyPassManager.cpp:1536:41
>>> #12 0x5397890 in runOnModule /local/repo/bbiswjenk/fem023-
>>> eiffel003/workspace/llvm/llvm-master-sanitize-asan/llvm/build-
>>> sana/../lib/IR/LegacyPassManager.cpp:1612:41
>>> #13 0x5397890 in llvm::legacy::PassManagerImpl::run(llvm::Module&)
>>> /local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-
>>> sanitize-asan/llvm/build-sana/../lib/IR/LegacyPassManager.cpp:1695
>>> #14 0x992e79 in compileModule(char**, llvm::LLVMContext&)
>>> /local/repo/bbiswjenk/fem023-eiffel003/workspace/llvm/llvm-master-
>>> sanitize-asan/llvm/build-sana/../tools/llc/llc.cpp:624:8
>>> #15 0x98d490 in main /local/repo/bbiswjenk/fem023-
>>> eiffel003/workspace/llvm/llvm-master-sanitize-asan/llvm/build-
>>> sana/../tools/llc/llc.cpp:360:22
>>> #16 0x7ff9852e7b96 in __libc_start_main /build/glibc-OTsEL5/glibc-
>>> 2.27/csu/../csu/libc-start.c:310
>>>
>>> SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).
>>>
>>> /Mikael
>>>
>>> >
>>> > On Fri, Apr 3, 2020 at 2:49 AM Mikael Holmén <
>>> > mikael.holmen at ericsson.com> wrote:
>>> > > Hi,
>>> > >
>>> > > I noticed on one of my organization's build bots that runs with
>>> > > sanatizers that we got a warning about a leak with this commit. So
>>> > > when
>>> > > running the testcase
>>> > > test/CodeGen/WebAssembly/irreducible-cfg-exceptions.ll
>>> > >
>>> > > build-sana/bin/llc < test/CodeGen/WebAssembly/irreducible-cfg-
>>> > > exceptions.ll -asm-verbose=false -verify-machineinstrs -disable-
>>> > > block-
>>> > > placement -wasm-disable-explicit-locals -wasm-keep-registers
>>> > > -enable-
>>> > > emscripten-cxx-exceptions | build-sana/bin/FileCheck
>>> > > test/CodeGen/WebAssembly/irreducible-cfg-exceptions.ll
>>> > >
>>> > > I get
>>> > >
>>> > > =================================================================
>>> > > ==5081==ERROR: LeakSanitizer: detected memory leaks
>>> > >
>>> > > Direct leak of 32 byte(s) in 1 object(s) allocated from:
>>> > > #0 0x421d520 (/data/repo/master/llvm/build-
>>> > > sana/bin/llc+0x421d520)
>>> > > #1 0x46a9ec9 (/data/repo/master/llvm/build-
>>> > > sana/bin/llc+0x46a9ec9)
>>> > > #2 0x676cc32 (/data/repo/master/llvm/build-
>>> > > sana/bin/llc+0x676cc32)
>>> > > #3 0x7bbf0ca (/data/repo/master/llvm/build-
>>> > > sana/bin/llc+0x7bbf0ca)
>>> > > #4 0x8e2374d (/data/repo/master/llvm/build-
>>> > > sana/bin/llc+0x8e2374d)
>>> > > #5 0x8e245e0 (/data/repo/master/llvm/build-
>>> > > sana/bin/llc+0x8e245e0)
>>> > > #6 0x4228f89 (/data/repo/master/llvm/build-
>>> > > sana/bin/llc+0x4228f89)
>>> > > #7 0x42235a0 (/data/repo/master/llvm/build-
>>> > > sana/bin/llc+0x42235a0)
>>> > > #8 0x7f50ee2f4b96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
>>> > >
>>> > > SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).
>>> > >
>>> > > /Mikael
>>> > >
>>> > > On Wed, 2020-04-01 at 16:33 -0700, Sam Clegg via llvm-commits
>>> > > wrote:
>>> > > > Author: Sam Clegg
>>> > > > Date: 2020-04-01T16:33:33-07:00
>>> > > > New Revision: 296ccef70363df9195bc678ad5501dd44de7f8fb
>>> > > >
>>> > > > URL:
>>> > > >
>>> > >
>>> 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
>>> > > > DIFF:
>>> > > >
>>> > >
>>> 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
>>> > > >
>>> > > > LOG: [WebAssembly] EmscriptenEHSjLj: Mark __invoke_ functions as
>>> > > > imported
>>> > > >
>>> > > > This means the linker will be expect them be undefined at link
>>> > > time
>>> > > > an
>>> > > > will generate imports from the `env` module rather than reporting
>>> > > > undefined externals.
>>> > > >
>>> > > > Differential Revision: https://reviews.llvm.org/D77192
>>> > > >
>>> > > > Added:
>>> > > >
>>> > > >
>>> > > > Modified:
>>> > > >
>>> > > llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
>>> > > > llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
>>> > > >
>>> > > > Removed:
>>> > > >
>>> > > >
>>> > > >
>>> > > >
>>> > > ###################################################################
>>> > > ##
>>> > > > ###########
>>> > > > diff --git
>>> > > >
>>> > > a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
>>> > > >
>>> > > b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
>>> > > > index 89265a3a9520..c8878a48b243 100644
>>> > > > ---
>>> > > >
>>> > > a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
>>> > > > +++
>>> > > >
>>> > > b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
>>> > > > @@ -344,6 +344,21 @@ static std::string getSignature(FunctionType
>>> > > > *FTy) {
>>> > > > return Sig;
>>> > > > }
>>> > > >
>>> > > > +static void markAsImported(Function *F) {
>>> > > > + // Tell the linker that this function is expected to be
>>> > > imported
>>> > > > from the
>>> > > > + // 'env' module.
>>> > > > + if (!F->hasFnAttribute("wasm-import-module")) {
>>> > > > + llvm::AttrBuilder B;
>>> > > > + B.addAttribute("wasm-import-module", "env");
>>> > > > + F->addAttributes(llvm::AttributeList::FunctionIndex, B);
>>> > > > + }
>>> > > > + if (!F->hasFnAttribute("wasm-import-name")) {
>>> > > > + llvm::AttrBuilder B;
>>> > > > + B.addAttribute("wasm-import-name", F->getName());
>>> > > > + F->addAttributes(llvm::AttributeList::FunctionIndex, B);
>>> > > > + }
>>> > > > +}
>>> > > > +
>>> > > > // Returns __cxa_find_matching_catch_N function, where N =
>>> > > > NumClauses + 2.
>>> > > > // This is because a landingpad instruction contains two more
>>> > > > arguments, a
>>> > > > // personality function and a cleanup bit, and
>>> > > > __cxa_find_matching_catch_N
>>> > > > @@ -360,6 +375,7 @@
>>> > > > WebAssemblyLowerEmscriptenEHSjLj::getFindMatchingCatch(Module &M,
>>> > > > Function *F = Function::Create(
>>> > > > FTy, GlobalValue::ExternalLinkage,
>>> > > > "__cxa_find_matching_catch_" + Twine(NumClauses + 2), &M);
>>> > > > + markAsImported(F);
>>> > > > FindMatchingCatches[NumClauses] = F;
>>> > > > return F;
>>> > > > }
>>> > > > @@ -469,6 +485,7 @@ Function
>>> > > > *WebAssemblyLowerEmscriptenEHSjLj::getInvokeWrapper(CallOrInvoke
>>> > > *CI)
>>> > > > {
>>> > > > CalleeFTy->isVarArg());
>>> > > > Function *F =
>>> > > > Function::Create(FTy, GlobalValue::ExternalLinkage,
>>> > > > "__invoke_" + Sig, M);
>>> > > > + markAsImported(F);
>>> > > > InvokeWrappers[Sig] = F;
>>> > > > return F;
>>> > > > }
>>> > > >
>>> > > > diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
>>> > > > b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
>>> > > > index cad6c4ac855b..ad42cc5f8615 100644
>>> > > > --- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
>>> > > > +++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
>>> > > > @@ -308,6 +308,10 @@ attributes #0 = { returns_twice }
>>> > > > attributes #1 = { noreturn }
>>> > > > attributes #2 = { nounwind }
>>> > > > attributes #3 = { allocsize(0) }
>>> > > > +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"
>>> > > > "wasm-import-name"="__invoke_void" }
>>> > > > +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"
>>> > > > "wasm-import-name"="__cxa_find_matching_catch_3" }
>>> > > > +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"
>>> > > > "wasm-import-name"="__invoke_i8*_i32_%struct.__jmp_buf_tag*" }
>>> > > > +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"
>>> > > > "wasm-import-name"="__invoke_void_%struct.__jmp_buf_tag*_i32" }
>>> > > > ; CHECK: attributes #[[ALLOCSIZE_ATTR]] = { allocsize(1) }
>>> > > >
>>> > > > !llvm.dbg.cu = !{!2}
>>> > > >
>>> > > >
>>> > > >
>>> > > > _______________________________________________
>>> > > > llvm-commits mailing list
>>> > > > llvm-commits at lists.llvm.org
>>> > > > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200406/e4812114/attachment.html>
More information about the llvm-commits
mailing list