| Issue |
208704
|
| Summary |
[clang][Parser] Segfault in CXXRecordDecl::hasConstexprDestructor during CheckConstexprFunctionDefinition after parser enters error recovery from ferror-limit
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
YuanchengJiang
|
The following code:
```cpp
template <int _Size> struct array {
};
template <class> struct allocator {
template <class> struct vector {
constexpr ~vector() {
}
allocator<array<2>> __alloc_;
```
Resulted in this output:
```
/tmp/test.cpp:8:1: error: unknown type name 'module'
8 | module "//d" {
| ^
/tmp/test.cpp:8:8: error: expected unqualified-id
8 | module "//d" {
| ^
/tmp/test.cpp:11:1: error: unknown type name 'module'
11 | module "//b" {
| ^
/tmp/test.cpp:11:8: error: expected unqualified-id
11 | module "//b" {
| ^
/tmp/test.cpp:15:1: error: unknown type name 'module'
15 | module "//e" {
| ^
/tmp/test.cpp:15:8: error: expected unqualified-id
15 | module "//e" {
| ^
/tmp/test.cpp:18:1: error: unknown type name 'module'
18 | module "//c" {
| ^
/tmp/test.cpp:18:8: error: expected unqualified-id
18 | module "//c" {
| ^
/tmp/test.cpp:21:1: error: unknown type name 'module'
21 | module "//f" {
| ^
/tmp/test.cpp:21:8: error: expected unqualified-id
21 | module "//f" {
| ^
/tmp/test.cpp:24:1: error: unknown type name 'module'
24 | module "//i" {
| ^
/tmp/test.cpp:24:8: error: expected unqualified-id
24 | module "//i" {
| ^
/tmp/test.cpp:27:1: error: unknown type name 'module'
27 | module "//g" {
| ^
/tmp/test.cpp:27:8: error: expected unqualified-id
27 | module "//g" {
| ^
/tmp/test.cpp:30:1: error: unknown type name 'module'
30 | module "//h" {
| ^
/tmp/test.cpp:30:8: error: expected unqualified-id
30 | module "//h" {
| ^
/tmp/test.cpp:33:1: error: unknown type name 'module'
33 | module "//k" {
| ^
/tmp/test.cpp:33:8: error: expected unqualified-id
33 | module "//k" {
| ^
/tmp/test.cpp:37:1: error: unknown type name 'module'
37 | module "//l" {
| ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
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: /usr/lib/llvm-22/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/fuzz/WorkSpace/fusion-fuzz/projects/clang -fcoverage-compilation-dir=/home/fuzz/WorkSpace/fusion-fuzz/projects/clang -resource-dir /usr/lib/llvm-22/lib/clang/22 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/x86_64-linux-gnu/c++/15 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/backward -internal-isystem /usr/lib/llvm-22/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -faddrsig -fdwarf2-cfi-asm -o /tmp/test-77a6cf.o -x c++ /tmp/test.cpp
1. <eof> parser at end of file
2. /tmp/test.cpp:90:1: parsing namespace 'std'
3. /tmp/test.cpp:91:8: parsing namespace 'std::(anonymous)'
4. /tmp/test.cpp:120:18: parsing struct/union/class body 'std::vector'
5. /tmp/test.cpp:121:23: parsing function body 'std::vector::~vector<type-parameter-0-0>'
#0 0x00007f81f8d095ea llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-22/bin/../lib/libLLVM.so.22.1+0x4e9f5ea)
#1 0x00007f81f8d06df7 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-22/bin/../lib/libLLVM.so.22.1+0x4e9cdf7)
#2 0x00007f81f8d0a334 (/usr/lib/llvm-22/bin/../lib/libLLVM.so.22.1+0x4ea0334)
#3 0x00007f81f38db970 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x40970)
#4 0x00007f81fe7d05ef clang::CXXRecordDecl::hasConstexprDestructor() const (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x191b5ef)
#5 0x00007f81ff19da50 (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x22e8a50)
#6 0x00007f81ff164778 clang::Sema::CheckConstexprFunctionDefinition(clang::FunctionDecl const*, clang::Sema::CheckConstexprKind) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x22af778)
#7 0x00007f81ff10fec7 clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool, bool) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x225aec7)
#8 0x00007f81fe59742c clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16e242c)
#9 0x00007f81fe4ef9da clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x163a9da)
#10 0x00007f81fe4ee76a clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x163976a)
#11 0x00007f81fe522188 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x166d188)
#12 0x00007f81fe520050 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x166b050)
#13 0x00007f81fe502ae6 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x164dae6)
#14 0x00007f81fe59e059 clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16e9059)
#15 0x00007f81fe59d6a8 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16e86a8)
#16 0x00007f81fe59d055 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16e8055)
#17 0x00007f81fe4fd622 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x1648622)
#18 0x00007f81fe5ac9b4 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16f79b4)
#19 0x00007f81fe518f2f clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x1663f2f)
#20 0x00007f81fe5188e9 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16638e9)
#21 0x00007f81fe4fd74c clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x164874c)
#22 0x00007f81fe5ac9b4 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16f79b4)
#23 0x00007f81fe518f2f clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x1663f2f)
#24 0x00007f81fe5188e9 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16638e9)
#25 0x00007f81fe4fd74c clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x164874c)
#26 0x00007f81fe5ac9b4 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16f79b4)
#27 0x00007f81fe5ab8f7 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x16f68f7)
#28 0x00007f81fe4ea67e clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x163567e)
#29 0x00007f8200224bef clang::FrontendAction::Execute() (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x336fbef)
#30 0x00007f8200198044 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x32e3044)
#31 0x00007f82002b2f9a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-22/bin/../lib/libclang-cpp.so.22.1+0x33fdf9a)
#32 0x000055fb08c99cdd cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-22/bin/clang+0x13cdd)
#33 0x000055fb08c9653b (/usr/lib/llvm-22/bin/clang+0x1053b)
#34 0x000055fb08c958a3 clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-22/bin/clang+0xf8a3)
#35 0x000055fb08ca49aa main (/usr/lib/llvm-22/bin/clang+0x1e9aa)
#36 0x00007f81f38c4f77 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29f77)
#37 0x00007f81f38c5027 __libc_start_main (/usr/lib/x86_64-linux-gnu/libc.so.6+0x2a027)
#38 0x000055fb08c941d1 _start (/usr/lib/llvm-22/bin/clang+0xe1d1)
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Debian clang version 22.1.8 (1+b1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-22/bin
clang++: note: diagnostic msg: Error generating preprocessed source(s).
```
To reproduce:
```
clang++ ./test.cpp
```
Compiler version:
```
Debian clang version 22.1.8 (1+b1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-22/bin
```
*This bug was found by [fusion-fuzz](https://github.com/fusion-fuzz/fusion-fuzz)*
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs