Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clang crashes while compiling my project #72880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ogigato opened this issue Nov 20, 2023 · 6 comments · Fixed by #138518
Closed

Clang crashes while compiling my project #72880

ogigato opened this issue Nov 20, 2023 · 6 comments · Fixed by #138518
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash-on-valid

Comments

@ogigato
Copy link

ogigato commented Nov 20, 2023

CLang version: 16.0.5, using MSVC-like command line. This project compiles ok using MSVC compiler, with the same arguments.

SourcesAndTrace.zip

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Nov 20, 2023
@tbaederr tbaederr added the needs-reduction Large reproducer that should be reduced into a simpler form label Nov 20, 2023
@EugeneZelenko EugeneZelenko added the crash Prefer [crash-on-valid] or [crash-on-invalid] label Nov 20, 2023
@shafik
Copy link
Collaborator

shafik commented Nov 28, 2023

I can't seem to open the zip file.

@ogigato
Copy link
Author

ogigato commented Nov 28, 2023 via email

@ogigato
Copy link
Author

ogigato commented Nov 29, 2023

Hi shafik, I have updated the zip file. I hope you can open it now.

BRs.

@Endilll
Copy link
Contributor

Endilll commented Feb 6, 2024

Confirmed in Clang 17 and post-18 trunk: https://godbolt.org/z/81qnjez5o
Reduced by me and C-Reduce:

struct stChildParam {};

struct RegParam : stChildParam {
  int count = 0;
};

template <typename _TFC>
struct DataGather {
  void AddParameters() {
    RegParam regPar = static_cast<RegParam>(stChildParam{});
  }
};

void f() {
  DataGather<int>{}.AddParameters();
}

Backtrace:

clang++: /root/llvm-project/clang/include/clang/AST/Type.h:753:
const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const:
Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.

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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1.	<eof> parser at end of file
2.	<source>:9:8: instantiating function definition 'DataGather<int>::AddParameters'
 #0 0x000000000388a128 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x388a128)
 #1 0x0000000003887e0c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3887e0c)
 #2 0x00000000037d02e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007ffb19e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007ffb19e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007ffb19e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007ffb19e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007ffb19e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007ffb19e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000062762fc (anonymous namespace)::CastOperation::CastOperation(clang::Sema&, clang::QualType, clang::ActionResult<clang::Expr*, true>) SemaCast.cpp:0:0
#10 0x00000000062832ae clang::Sema::BuildCXXNamedCast(clang::SourceLocation, clang::tok::TokenKind, clang::TypeSourceInfo*, clang::Expr*, clang::SourceRange, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62832ae)
#11 0x0000000006c38fdf clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCXXNamedCastExpr(clang::CXXNamedCastExpr*) SemaTemplateInstantiate.cpp:0:0
#12 0x0000000006c03d78 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#13 0x0000000006c05be0 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool) (.part.0) SemaTemplateInstantiate.cpp:0:0
#14 0x0000000006c06221 clang::Sema::SubstInitializer(clang::Expr*, clang::MultiLevelTemplateArgumentList const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c06221)
#15 0x0000000006c4ecaf clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c4ecaf)
#16 0x0000000006c9052d clang::Sema::BuildVariableInstantiation(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&, llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*, clang::DeclContext*, clang::LocalInstantiationScope*, bool, clang::VarTemplateSpecializationDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c9052d)
#17 0x0000000006c99f2b clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool, llvm::ArrayRef<clang::BindingDecl*>*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c99f2b)
#18 0x0000000006c9ea74 void llvm::function_ref<void ()>::callback_fn<clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)::'lambda'()>(long) SemaTemplateInstantiateDecl.cpp:0:0
#19 0x00000000062274e1 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62274e1)
#20 0x0000000006c4cb8a clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c4cb8a)
#21 0x0000000006bfd585 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*) SemaTemplateInstantiate.cpp:0:0
#22 0x0000000006c3c4a4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#23 0x0000000006c4296a clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c4296a)
#24 0x0000000006c93ff1 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c93ff1)
#25 0x0000000006c9240f clang::Sema::PerformPendingInstantiations(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c9240f)
#26 0x000000000624a6a9 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (.part.0) Sema.cpp:0:0
#27 0x000000000624ae82 clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x624ae82)
#28 0x00000000060d06d1 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x60d06d1)
#29 0x00000000060c341a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x60c341a)
#30 0x0000000004118c48 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4118c48)
#31 0x0000000004389719 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4389719)
#32 0x00000000043081ee clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43081ee)
#33 0x000000000446940e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x446940e)
#34 0x0000000000c126b6 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc126b6)
#35 0x0000000000c09eca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x000000000415a1f9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#37 0x00000000037d0794 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37d0794)
#38 0x000000000415a7ef clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#39 0x00000000041224e5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41224e5)
#40 0x0000000004122f4d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4122f4d)
#41 0x000000000412ae85 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x412ae85)
#42 0x0000000000c0fa3c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc0fa3c)
#43 0x0000000000b06be4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb06be4)
#44 0x00007ffb19e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#45 0x00007ffb19e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#46 0x0000000000c099ae _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc099ae)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

@Endilll Endilll added c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash-on-valid and removed clang Clang issues not falling into any other category crash Prefer [crash-on-valid] or [crash-on-invalid] needs-reduction Large reproducer that should be reduced into a simpler form labels Feb 6, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2024

@llvm/issue-subscribers-clang-frontend

Author: None (ogigato)

CLang version: 16.0.5, using MSVC-like command line. This project compiles ok using MSVC compiler, with the same arguments.

SourcesAndTrace.zip

@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2024

@llvm/issue-subscribers-c-20

Author: None (ogigato)

CLang version: 16.0.5, using MSVC-like command line. This project compiles ok using MSVC compiler, with the same arguments.

SourcesAndTrace.zip

cor3ntin added a commit that referenced this issue May 5, 2025
We were converting a CXXParenListInitExpr to a ParenListExpr in
TreeTransform.

However, ParenListExpr is typeless, so Clang could not rebuild the
correct initialization sequence in some contexts.

Fixes #72880
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
We were converting a CXXParenListInitExpr to a ParenListExpr in
TreeTransform.

However, ParenListExpr is typeless, so Clang could not rebuild the
correct initialization sequence in some contexts.

Fixes llvm#72880
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
We were converting a CXXParenListInitExpr to a ParenListExpr in
TreeTransform.

However, ParenListExpr is typeless, so Clang could not rebuild the
correct initialization sequence in some contexts.

Fixes llvm#72880
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
We were converting a CXXParenListInitExpr to a ParenListExpr in
TreeTransform.

However, ParenListExpr is typeless, so Clang could not rebuild the
correct initialization sequence in some contexts.

Fixes llvm#72880
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this issue May 7, 2025
We were converting a CXXParenListInitExpr to a ParenListExpr in
TreeTransform.

However, ParenListExpr is typeless, so Clang could not rebuild the
correct initialization sequence in some contexts.

Fixes llvm#72880
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash-on-valid
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants