r236422 - Revert "Frontend: Stop leaking when not -disable-free"

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon May 4 06:39:58 PDT 2015


> On 2015 May 4, at 09:12, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
> 
>> On 2015 May 4, at 09:01, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
>> 
>> Author: dexonsmith
>> Date: Mon May  4 08:01:42 2015
>> New Revision: 236422
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=236422&view=rev
>> Log:
>> Revert "Frontend: Stop leaking when not -disable-free"
>> 
>> This reverts commit r236419, since it caused some bots to fail.  On:
>> 
>> http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/26124
>> http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/35086
> 
> Also failed on:
> 
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/26099
> 
> Can anyone with access to a Linux box investigate?  It's not
> clear to me what's going on here, since the tests pass locally
> (on Darwin).

Nevermind.  ASan has me covered:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/3594/steps/check-clang%20asan/logs/stdio

==1154==ERROR: AddressSanitizer: heap-use-after-free on address 0x60600000d5e8 at pc 0x0000059dfa4f bp 0x7fffa1d22a70 sp 0x7fffa1d22a68
READ of size 1 at 0x60600000d5e8 thread T0
    #0 0x59dfa4e in classof /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/SemaConsumer.h:43:7
    #1 0x59dfa4e in doit /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Casting.h:56
    #2 0x59dfa4e in doit /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Casting.h:96
    #3 0x59dfa4e in doit /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Casting.h:122
    #4 0x59dfa4e in doit /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Casting.h:112
    #5 0x59dfa4e in isa<clang::SemaConsumer, clang::ASTConsumer *> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Casting.h:133
    #6 0x59dfa4e in dyn_cast<clang::SemaConsumer, clang::ASTConsumer> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Casting.h:298
    #7 0x59dfa4e in clang::Sema::~Sema() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/Sema.cpp:256
    #8 0x391242c in operator() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:2470:13
    #9 0x391242c in reset /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:2669
    #10 0x391242c in clang::CompilerInstance::setSema(clang::Sema*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:101
    #11 0x39b4c7e in clang::FrontendAction::EndSourceFile() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:505:7
    #12 0x3921871 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:815:7
    #13 0x3b55df5 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:222:18
    #14 0x89acb7 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/cc1_main.cpp:110:13
    #15 0x8964cd in ExecuteCC1Tool /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:369:12
    #16 0x8964cd in main /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:415
    #17 0x7f22779bfeac in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x1eeac)
    #18 0x7fd440 in _start (/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/clang-3.7+0x7fd440)

0x60600000d5e8 is located 8 bytes inside of 64-byte region [0x60600000d5e0,0x60600000d620)
freed by thread T0 here:
    #0 0x88f7f9 in operator delete(void*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:94
    #1 0x39b46da in clang::FrontendAction::EndSourceFile() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:481:5
    #2 0x3921871 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:815:7
    #3 0x3b55df5 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:222:18
    #4 0x89acb7 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/cc1_main.cpp:110:13
    #5 0x8964cd in ExecuteCC1Tool /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:369:12
    #6 0x8964cd in main /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:415
    #7 0x7f22779bfeac in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x1eeac)

previously allocated by thread T0 here:
    #0 0x88f201 in operator new(unsigned long) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:62
    #1 0x3a73dd4 in make_unique<(anonymous namespace)::ASTPrinter, llvm::raw_ostream *&, bool, llvm::StringRef &> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/STLExtras.h:346:3
    #2 0x3a73dd4 in clang::CreateASTPrinter(llvm::raw_ostream*, llvm::StringRef) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/ASTConsumers.cpp:127
    #3 0x39b7fbd in clang::ASTPrintAction::CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/FrontendActions.cpp:51:12
    #4 0x39ae1fb in clang::FrontendAction::CreateWrappedASTConsumer(clang::CompilerInstance&, llvm::StringRef) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:140:43
    #5 0x39afe93 in clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:217:23
    #6 0x3921852 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:813:9
    #7 0x3b55df5 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:222:18
    #8 0x89acb7 in cc1_main(ll
vm::ArrayRef<char const*>, char const*, void*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/cc1_main.cpp:110:13

    #9 0x8964cd in ExecuteCC1Tool /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:369:12
    #10 0x8964cd in main /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:415
    #11 0x7f22779bfeac in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x1eeac)

Looks like a destruction order problem.  I'll build with ASan and
try to reorder `FrontendAction::EndSourceFile()`.

> 
>> 
>> these tests:
>> 
>> FAIL: Clang::import-decl.cpp
>> FAIL: Clang::floating-literal.c
>> FAIL: Clang::x86_64-linux-android.c
>> 
>> fail with this output:
>> 
>> Command Output (stderr):
>> --
>> Stack dump:
>> 0.  Program arguments: /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/clang -cc1 -internal-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../lib/clang/3.7.0/include -nostdsysteminc -ast-print -x ast -
>> /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/tools/clang/test/Modules/Output/import-decl.cpp.script: line 3:  9665 Segmentation fault      (core dumped) /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/clang -cc1 -internal-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../lib/clang/3.7.0/include -nostdsysteminc -ast-print -x ast - < /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/tools/clang/test/Modules/Output/import-decl.cpp.tmp.ast
>>     9666 Done                    | /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/FileCheck /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.src/tools/clang/test/Modules/import-decl.cpp
>> 
>> --
>> 
>> Modified:
>>   cfe/trunk/lib/Frontend/FrontendAction.cpp
>> 
>> Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=236422&r1=236421&r2=236422&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
>> +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Mon May  4 08:01:42 2015
>> @@ -494,20 +494,13 @@ void FrontendAction::EndSourceFile() {
>>  // FrontendAction.
>>  CI.clearOutputFiles(/*EraseFiles=*/shouldEraseOutputFiles());
>> 
>> +  // FIXME: Only do this if DisableFree is set.
>>  if (isCurrentFileAST()) {
>> -    if (DisableFree) {
>> -      CI.resetAndLeakSema();
>> -      CI.resetAndLeakASTContext();
>> -      CI.resetAndLeakPreprocessor();
>> -      CI.resetAndLeakSourceManager();
>> -      CI.resetAndLeakFileManager();
>> -    } else {
>> -      CI.setSema(nullptr);
>> -      CI.setASTContext(nullptr);
>> -      CI.setPreprocessor(nullptr);
>> -      CI.setSourceManager(nullptr);
>> -      CI.setFileManager(nullptr);
>> -    }
>> +    CI.resetAndLeakSema();
>> +    CI.resetAndLeakASTContext();
>> +    CI.resetAndLeakPreprocessor();
>> +    CI.resetAndLeakSourceManager();
>> +    CI.resetAndLeakFileManager();
>>  }
>> 
>>  setCompilerInstance(nullptr);
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 





More information about the cfe-commits mailing list