[llvm-bugs] [Bug 47962] New: clang crashes while using -ast-merge and -emit-pch in some cases

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 25 04:21:35 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47962

            Bug ID: 47962
           Summary: clang crashes while using -ast-merge and -emit-pch in
                    some cases
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: 0 at void.re
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

I've tested clang-6.0, clang-8, clang-10, clang-11 and now trunk, they all
crash on this issue.

$ cat test1.c
#include <stdio.h>

void func1(void)
{
}
$ cat test2.c
void test2(void)
{
}
$ ../clang-12 -emit-ast test1.c
$ ../clang-12 -emit-ast test2.c
$ ../clang-12 -cc1 -ast-merge test1.ast -ast-merge test2.ast /dev/null
-emit-pch -o out.ast
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: ../clang-12 -cc1 -ast-merge test1.ast -ast-merge
test2.ast /dev/null -emit-pch -o out.ast 
1.      <eof> parser at end of file
 #0 0x000055e39a5282ec llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/user/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:22
 #1 0x000055e39a5283a7 PrintStackTraceSignalHandler(void*)
/home/user/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:630:1
 #2 0x000055e39a526043 llvm::sys::RunSignalHandlers()
/home/user/git/llvm-project/llvm/lib/Support/Signals.cpp:71:20
 #3 0x000055e39a527c39 SignalHandler(int)
/home/user/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:405:1
 #4 0x00007f0d9df983c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #5 0x000055e39a49691e llvm::djbHash(llvm::StringRef, unsigned int)
/home/user/git/llvm-project/llvm/include/llvm/Support/DJB.h:22:22
 #6 0x000055e39b4bc418 (anonymous
namespace)::ASTIdentifierTableTrait::ComputeHash(clang::IdentifierInfo const*)
/home/user/git/llvm-project/clang/lib/Serialization/ASTWriter.cpp:3310:3
 #7 0x000055e39b4e2bac llvm::OnDiskChainedHashTableGenerator<(anonymous
namespace)::ASTIdentifierTableTrait>::Item::Item(clang::IdentifierInfo*,
unsigned int, (anonymous namespace)::ASTIdentifierTableTrait&)
/home/user/git/llvm-project/llvm/include/llvm/Support/OnDiskHashTable.h:70:77
 #8 0x000055e39b4df89f llvm::OnDiskChainedHashTableGenerator<(anonymous
namespace)::ASTIdentifierTableTrait>::insert(clang::IdentifierInfo*, unsigned
int, (anonymous namespace)::ASTIdentifierTableTrait&)
/home/user/git/llvm-project/llvm/include/llvm/Support/OnDiskHashTable.h:130:21
 #9 0x000055e39b4bcea7
clang::ASTWriter::WriteIdentifierTable(clang::Preprocessor&,
clang::IdentifierResolver&, bool)
/home/user/git/llvm-project/clang/lib/Serialization/ASTWriter.cpp:3453:29
#10 0x000055e39b4d0c38 clang::ASTWriter::WriteASTCore(clang::Sema&,
llvm::StringRef, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, clang::Module*)
/home/user/git/llvm-project/clang/lib/Serialization/ASTWriter.cpp:4792:54
#11 0x000055e39b4ce69a clang::ASTWriter::WriteAST(clang::Sema&,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, clang::Module*, llvm::StringRef, bool, bool)
/home/user/git/llvm-project/clang/lib/Serialization/ASTWriter.cpp:4386:64
#12 0x000055e39b565b48
clang::PCHGenerator::HandleTranslationUnit(clang::ASTContext&)
/home/user/git/llvm-project/clang/lib/Serialization/GeneratePCH.cpp:72:45
#13 0x000055e39b1e0134
clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/user/git/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp:291:25
#14 0x000055e39d705239 clang::ParseAST(clang::Sema&, bool, bool)
/home/user/git/llvm-project/clang/lib/Parse/ParseAST.cpp:178:14
#15 0x000055e39b19d8a3 clang::ASTFrontendAction::ExecuteAction()
/home/user/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1056:11
#16 0x000055e39d6928f8 clang::ASTMergeAction::ExecuteAction()
/home/user/git/llvm-project/clang/lib/Frontend/ASTMerge.cpp:80:21
#17 0x000055e39b19d162 clang::FrontendAction::Execute()
/home/user/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:953:38
#18 0x000055e39b12f613
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/user/git/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:989:42
#19 0x000055e39b334614
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/user/git/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:38
#20 0x000055e397671279 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/user/git/llvm-project/clang/tools/driver/cc1_main.cpp:240:40
#21 0x000055e397665923 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/user/git/llvm-project/clang/tools/driver/driver.cpp:330:20
#22 0x000055e3976660e9 main
/home/user/git/llvm-project/clang/tools/driver/driver.cpp:407:26
#23 0x00007f0d9da190b3 __libc_start_main
/build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3
#24 0x000055e397663fbe _start (../clang-12+0x2b7ffbe)

It does merges everything correctly into 1 ast/pch file when #include <stdio.h>
is excluded from test1.c

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201025/b232b412/attachment-0001.html>


More information about the llvm-bugs mailing list