| Issue |
63789
|
| Summary |
Clang/LLVM Parse Bug
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
frobnitzem
|
While compiling a large header-based library, I ran into a segfault that appears to be coming from the clang C++ source parser. For this particular package, the `grid_generator.cc` file is the only one of its cc source files that displays the error. All its other sources compile fine with llvm. I originally used a few system-specific modified llvm-15 versions, but have since reproduced the error with basic llvm-12 and llvm-14. gcc-7.5 does not have the error. Apple-clang 14 on my macbook also does not have the error.
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang++ -Iinc -Iinc/mpi -Iinc/dealii -Iinc/boost-1.70.0/include -std=c++14 -o tmp.o -c grid_generator.cc
1. grid_generator.cc:6106:3: current parser token 'template'
2. grid_generator.cc:36:1 <Spelling=inc/dealii/deal.II/base/config.h:73:32>: parsing namespace 'dealii'
3. grid_generator.cc:42:1: parsing namespace 'dealii::double free or corruption (out)
build.sh: line 7: 3328785 Aborted (core dumped) clang++ -Iinc -Iinc/mpi -Iinc/dealii -Iinc/boost-1.70.0/include -std=c++14 -o tmp.o -c grid_generator.cc
```
A reproducer for the bug is here (in the `build.sh` script):
https://github.com/frobnitzem/llvm-parse-bug1
Changing the text of the source file slightly around the indicated error token does not resolve the issue,
but sometimes causes the error message to blame a file location thousands of lines away (e.g. 3059,2023, etc.).
Other versions of clang have more verbose output. In particular, Cray clang version 15.0.0 (324a8e7de6a18594c06a0ee5d8c0eda2109c6ac6) shows:
```
...
# define BOOST_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T) && !is_volatile<T>::value && is_assignable<T&, const T&>::value)
^
inc/boost-1.70.0/include/boost/signals2/detail/auto_buffer.hpp:157:51: note: in instantiation of template class 'boost::has_trivial_assign<boost::variant<boost::shared_ptr<void>, boost::signals2::detail::foreign_void_shared_ptr>>' requested here
typedef typename boost::mpl::if_c< boost::has_trivial_assign<T>::value
^
inc/boost-1.70.0/include/boost/signals2/detail/slot_call_iterator.hpp:65:27: note: in instantiation of template class 'boost::signals2::detail::auto_buffer<boost::variant<boost::shared_ptr<void>, boost::signals2::detail::foreign_void_shared_ptr>, boost::signals2::detail::store_n_objects<10>>' requested here
tracked_ptrs_type tracked_ptrs;
^
Didn't find this decl on its identifier's chain!
UNREACHABLE executed at /home/jenkins/clang/lib/Sema/IdentifierResolver.cpp:82!
PLEASE submit a bug report to Cray and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang++ -Iinc -Iinc/mpi -Iinc/dealii -Iinc/boost-1.70.0/include -std=c++14 -o tmp.o -c grid_generator.cc
1. grid_generator.cc:6106:3: current parser token 'template'
2. grid_generator.cc:36:1 <Spelling=inc/dealii/deal.II/base/config.h:394:32>: parsing namespace 'dealii'
3. grid_generator.cc:42:1: parsing namespace 'dealii::GridGenerator'
4. grid_generator.cc:5898:3: parsing function body 'dealii::GridGenerator::hyper_shell<3>'
#0 0x00000000038ef25f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x00000000038ec9c3 llvm::sys::CleanupOnSignal(unsigned long) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x38ec9c3)
#2 0x0000000003828387 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f0bb27f78bf (/lib64/libpthread.so.0+0x168bf)
#4 0x00007f0bb14dbcba raise (/lib64/libc.so.6+0x4acba)
#5 0x00007f0bb14dd354 abort (/lib64/libc.so.6+0x4c354)
#6 0x0000000003836719 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x3836719)
#7 0x0000000005a62466 clang::IdentifierResolver::IdDeclInfo::RemoveDecl(clang::NamedDecl*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5a62466)
#8 0x0000000005a629ab clang::IdentifierResolver::RemoveDecl(clang::NamedDecl*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5a629ab)
#9 0x0000000005c35e56 clang::Sema::ActOnPopScope(clang::SourceLocation, clang::Scope*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5c35e56)
#10 0x000000000594c824 clang::Parser::ExitScope() (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x594c824)
#11 0x0000000005a26e1c clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5a26e1c)
#12 0x0000000005956326 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5956326)
#13 0x0000000005a38223 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5a38223)
#14 0x0000000005a4526d clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5a4526d)
#15 0x0000000005a4550c clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5a4550c)
#16 0x0000000005987ba4 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5987ba4)
#17 0x000000000595898b clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x595898b)
#18 0x000000000599ba16 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x599ba16)
#19 0x000000000599eae8 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x599eae8)
#20 0x0000000005987d99 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5987d99)
#21 0x000000000595898b clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x595898b)
#22 0x000000000599ba16 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x599ba16)
#23 0x000000000599eae8 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x599eae8)
#24 0x0000000005987d99 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5987d99)
#25 0x000000000595898b clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x595898b)
#26 0x000000000595991d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x595991d)
#27 0x0000000005949941 clang::ParseAST(clang::Sema&, bool, bool) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x5949941)
#28 0x00000000044cdd98 clang::FrontendAction::Execute() (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x44cdd98)
#29 0x000000000444a635 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x444a635)
#30 0x000000000459807a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x459807a)
#31 0x0000000000e1eaa9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0xe1eaa9)
#32 0x0000000000e1989b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#33 0x00000000042787d4 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#34 0x00000000038284f3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x38284f3)
#35 0x000000000427a9e5 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x427a9e5)
#36 0x000000000423c24e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x423c24e)
#37 0x000000000423d4ac clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x423d4ac)
#38 0x000000000424c99b clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0x424c99b)
#39 0x0000000000e1badd clang_main(int, char**) (/opt/cray/pe/cce/15.0.0/cce-clang/x86_64/bin/clang-15+0xe1badd)
#40 0x00007f0bb14c629c __libc_start_main (/lib64/libc.so.6+0x3529c)
#41 0x0000000000e16b49 _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:120:0
clang-15: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs