[cfe-dev] cc1 problems when loading multiple AST files

Ella Oikawa via cfe-dev cfe-dev at lists.llvm.org
Sun Apr 14 20:23:20 PDT 2019


Hi,

The scene of my usage is I want to analyze multiple source code files with
CSA and CTU enabled. Since it will report a header file not found error
when using `clang -cc1` to analyze source code files (*.cpp), I turn to AST
files for simplicity.

Here is the bug. If I only analyze a single AST file, it works fine.
However, when I append multiple AST files for analysis, it crashes all the
time. It has been reproduced both on my fedora-29 desktop and ubuntu-18.04
server with the code from git commit e03301a3b32.

The code I use to trigger this bug is provided in the attachments. See core
dump file (./coredump) for more details. According to the stack trace, I
think the bug is not in CSA and CTU.

**Besides, could you please tell me how to make cc1 to parse AST with the
compile commands provided in the compile_commands.json file? Or make
clang-check enable CTU IPA? I did not find any code to enable CTU IPA in
clang-check, and if it is useful to others, I would like to share my
customized clang-check.**

Regards,
Ella

P.S. I do not know whether it is allowed to ask a question together with a
bug report here. Sorry for annoying you.

---

$ clang --version
clang version 9.0.0 (https://github.com/llvm/llvm-project.git
e03301a3b32d048d8975e0fe21d80489505415c8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/ella/workspace/llvm-project/build/bin

ERROR MESSAGE:
clang:
/home/ella/workspace/llvm-project/clang/include/clang/Basic/Diagnostic.h:528:
void clang::DiagnosticsEngine::setSourceManager(clang::SourceManager*):
Assertion `DiagStatesByLoc.empty() && "Leftover diag state from a different
SourceManager."' failed.
Stack dump:
0. Program arguments: ../bin/clang -cc1 -analyze
-analyzer-checker=core,debug.ExprInspection -o reports/
home/ella/workspace/llvm-project/build/analyzer-test/src/getzero.cpp.ast
home/ella/workspace/llvm-project/build/analyzer-test/src/test.cpp.ast
 #0 0x000000000457075a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/ella/workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:494:22
 #1 0x00000000045707ed PrintStackTraceSignalHandler(void*)
/home/ella/workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:558:1
 #2 0x000000000456eabf llvm::sys::RunSignalHandlers()
/home/ella/workspace/llvm-project/llvm/lib/Support/Signals.cpp:68:20
 #3 0x0000000004570250 SignalHandler(int)
/home/ella/workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:357:1
 #4 0x00007f52db212070 __restore_rt (/lib64/libpthread.so.0+0x13070)
 #5 0x00007f52d94ec57f __GI_raise (/lib64/libc.so.6+0x3857f)
 #6 0x00007f52d94d6895 __GI_abort (/lib64/libc.so.6+0x22895)
 #7 0x00007f52d94d6769 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x22769)
 #8 0x00007f52d94e4a26 (/lib64/libc.so.6+0x30a26)
 #9 0x000000000476fa4b
clang::DiagnosticsEngine::setSourceManager(clang::SourceManager*)
/home/ella/workspace/llvm-project/clang/include/clang/Basic/Diagnostic.h:527:5
#10 0x0000000004768d72
clang::SourceManager::SourceManager(clang::DiagnosticsEngine&,
clang::FileManager&, bool)
/home/ella/workspace/llvm-project/clang/lib/Basic/SourceManager.cpp:319:1
#11 0x0000000004fba66c
clang::ASTUnit::LoadFromASTFile(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
clang::PCHContainerReader const&, clang::ASTUnit::WhatToLoad,
llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>,
clang::FileSystemOptions const&, bool, bool,
llvm::ArrayRef<std::pair<std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >, llvm::MemoryBuffer*> >,
bool, bool, bool)
/home/ella/workspace/llvm-project/clang/lib/Frontend/ASTUnit.cpp:760:58
#12 0x0000000004eb1850
clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&,
clang::FrontendInputFile const&)
/home/ella/workspace/llvm-project/clang/lib/Frontend/FrontendAction.cpp:632:69
#13 0x0000000004e5576f
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/ella/workspace/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:949:5
#14 0x0000000004ff5b4b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/ella/workspace/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:271:38
#15 0x000000000221e5d9 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/home/ella/workspace/llvm-project/clang/tools/driver/cc1_main.cpp:225:40
#16 0x0000000002214598 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef)
/home/ella/workspace/llvm-project/clang/tools/driver/driver.cpp:309:64
#17 0x0000000002214bea main
/home/ella/workspace/llvm-project/clang/tools/driver/driver.cpp:381:26
#18 0x00007f52d94d8413 __libc_start_main (/lib64/libc.so.6+0x24413)
#19 0x0000000002212f3e _start (../bin/clang+0x2212f3e)
[1]    32214 abort (core dumped)  ../bin/clang -cc1 -analyze
-analyzer-checker=core,debug.ExprInspection -o
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190415/454dcf21/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trigger.tar.xz
Type: application/x-xz
Size: 3592052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190415/454dcf21/attachment.bin>


More information about the cfe-dev mailing list