Skip to content
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

Crash Issue during Clang-19.0.0.git Compilation Due to Recursive Call in Code #87957

Open
iamanonymouscs opened this issue Apr 8, 2024 · 4 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@iamanonymouscs
Copy link

Command

clang bug_1.cc

Code

int foo(void)
{
  return foo();
}

int foo() __attribute__((target("default")));
int foo() __attribute__((target("default")));
int foo() __attribute__((target("arch=core2")));

int bar()
{
  return foo();
}

Version

clang --version

clang version 19.0.0git (https://github.com/llvm/llvm-project.git 987087df90026605fc8d03ebda5a1cd31b71e609)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Error Output

bug_1.cc:6:26: warning: attribute declaration must precede definition [-Wignored-attributes]
    6 | int foo() __attribute__((target("default")));
      |                          ^
bug_1.cc:1:5: note: previous definition is here
    1 | int foo(void)
      |     ^
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: /home/cTest/llvm-project/mybuild/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bug_1.cc -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/cTest -fcoverage-compilation-dir=/home/cTest -resource-dir /home/cTest/llvm-project/mybuild/lib/clang/19 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /home/cTest/llvm-project/mybuild/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../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 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/bug_1-0036ac.o -x c++ bug_1.cc
1.      bug_1.cc:7:45: current parser token ';'
 #0 0x00005591a9339bcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x37ddbcf)
 #1 0x00005591a93373d4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f01253d9420 __restore_rt (/usr/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00005591a6945de9 CheckMultiVersionAdditionalDecl(clang::Sema&, clang::FunctionDecl*, clang::FunctionDecl*, clang::MultiVersionKind, clang::CPUDispatchAttr const*, clang::CPUSpecificAttr const*, clang::TargetClonesAttr const*, bool&, clang::NamedDecl*&, clang::LookupResult&) (.cold) SemaDecl.cpp:0:0
 #4 0x00005591aba2bc41 clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5ecfc41)
 #5 0x00005591aba313cb clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5ed53cb)
 #6 0x00005591aba34c3f clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5ed8c3f)
 #7 0x00005591aba356e5 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5ed96e5)
 #8 0x00005591ab6c8e5d clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b6ce5d)
 #9 0x00005591ab6dcd3e clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b80d3e)
#10 0x00005591ab6969c9 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b3a9c9)
#11 0x00005591ab69754e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b3b54e)
#12 0x00005591ab69fa2f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b43a2f)
#13 0x00005591ab6a1617 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b45617)
#14 0x00005591ab69054a clang::ParseAST(clang::Sema&, bool, bool) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b3454a)
#15 0x00005591a9b83b55 clang::CodeGenAction::ExecuteAction() (/home/cTest/llvm-project/mybuild/bin/clang-19+0x4027b55)
#16 0x00005591a9e15191 clang::FrontendAction::Execute() (/home/cTest/llvm-project/mybuild/bin/clang-19+0x42b9191)
#17 0x00005591a9d904eb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x42344eb)
#18 0x00005591a9ef511b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x439911b)
#19 0x00005591a6a4dced cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0xef1ced)
#20 0x00005591a6a4657d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x00005591a6a4ad96 clang_main(int, char**, llvm::ToolContext const&) (/home/cTest/llvm-project/mybuild/bin/clang-19+0xeeed96)
#22 0x00005591a6950fdb main (/home/cTest/llvm-project/mybuild/bin/clang-19+0xdf4fdb)
#23 0x00007f0124e87083 __libc_start_main (/usr/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#24 0x00005591a6a45d3e _start (/home/cTest/llvm-project/mybuild/bin/clang-19+0xee9d3e)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 987087df90026605fc8d03ebda5a1cd31b71e609)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cTest/llvm-project/mybuild/bin
clang: note: diagnostic msg: 
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Apr 8, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 8, 2024

@llvm/issue-subscribers-clang-frontend

Author: Anonymous (iamanonymouscs)

# Command `clang bug_1.cc` # Code ```c int foo(void) { return foo(); }

int foo() attribute((target("default")));
int foo() attribute((target("default")));
int foo() attribute((target("arch=core2")));

int bar()
{
return foo();
}

# Version
`clang --version`
```sh
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 987087df90026605fc8d03ebda5a1cd31b71e609)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Error Output

bug_1.cc:6:26: warning: attribute declaration must precede definition [-Wignored-attributes]
    6 | int foo() __attribute__((target("default")));
      |                          ^
bug_1.cc:1:5: note: previous definition is here
    1 | int foo(void)
      |     ^
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: /home/cTest/llvm-project/mybuild/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bug_1.cc -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/cTest -fcoverage-compilation-dir=/home/cTest -resource-dir /home/cTest/llvm-project/mybuild/lib/clang/19 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /home/cTest/llvm-project/mybuild/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../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 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/bug_1-0036ac.o -x c++ bug_1.cc
1.      bug_1.cc:7:45: current parser token ';'
 #<!-- -->0 0x00005591a9339bcf llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x37ddbcf)
 #<!-- -->1 0x00005591a93373d4 SignalHandler(int) Signals.cpp:0:0
 #<!-- -->2 0x00007f01253d9420 __restore_rt (/usr/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #<!-- -->3 0x00005591a6945de9 CheckMultiVersionAdditionalDecl(clang::Sema&amp;, clang::FunctionDecl*, clang::FunctionDecl*, clang::MultiVersionKind, clang::CPUDispatchAttr const*, clang::CPUSpecificAttr const*, clang::TargetClonesAttr const*, bool&amp;, clang::NamedDecl*&amp;, clang::LookupResult&amp;) (.cold) SemaDecl.cpp:0:0
 #<!-- -->4 0x00005591aba2bc41 clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&amp;, bool, bool) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5ecfc41)
 #<!-- -->5 0x00005591aba313cb clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&amp;, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&amp;, llvm::MutableArrayRef&lt;clang::TemplateParameterList*&gt;, bool&amp;) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5ed53cb)
 #<!-- -->6 0x00005591aba34c3f clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&amp;, llvm::MutableArrayRef&lt;clang::TemplateParameterList*&gt;) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5ed8c3f)
 #<!-- -->7 0x00005591aba356e5 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&amp;) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5ed96e5)
 #<!-- -->8 0x00005591ab6c8e5d clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::Parser::ForRangeInit*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b6ce5d)
 #<!-- -->9 0x00005591ab6dcd3e clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, clang::DeclaratorContext, clang::ParsedAttributes&amp;, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b80d3e)
#<!-- -->10 0x00005591ab6969c9 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec&amp;, clang::AccessSpecifier) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b3a9c9)
#<!-- -->11 0x00005591ab69754e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b3b54e)
#<!-- -->12 0x00005591ab69fa2f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b43a2f)
#<!-- -->13 0x00005591ab6a1617 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b45617)
#<!-- -->14 0x00005591ab69054a clang::ParseAST(clang::Sema&amp;, bool, bool) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x5b3454a)
#<!-- -->15 0x00005591a9b83b55 clang::CodeGenAction::ExecuteAction() (/home/cTest/llvm-project/mybuild/bin/clang-19+0x4027b55)
#<!-- -->16 0x00005591a9e15191 clang::FrontendAction::Execute() (/home/cTest/llvm-project/mybuild/bin/clang-19+0x42b9191)
#<!-- -->17 0x00005591a9d904eb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x42344eb)
#<!-- -->18 0x00005591a9ef511b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0x439911b)
#<!-- -->19 0x00005591a6a4dced cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/home/cTest/llvm-project/mybuild/bin/clang-19+0xef1ced)
#<!-- -->20 0x00005591a6a4657d ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->21 0x00005591a6a4ad96 clang_main(int, char**, llvm::ToolContext const&amp;) (/home/cTest/llvm-project/mybuild/bin/clang-19+0xeeed96)
#<!-- -->22 0x00005591a6950fdb main (/home/cTest/llvm-project/mybuild/bin/clang-19+0xdf4fdb)
#<!-- -->23 0x00007f0124e87083 __libc_start_main (/usr/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#<!-- -->24 0x00005591a6a45d3e _start (/home/cTest/llvm-project/mybuild/bin/clang-19+0xee9d3e)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 987087df90026605fc8d03ebda5a1cd31b71e609)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cTest/llvm-project/mybuild/bin
clang: note: diagnostic msg: 

@mahtohappy
Copy link
Contributor

https://godbolt.org/z/x41Yj51a6 see if this what you're trying to do.

@iamanonymouscs
Copy link
Author

https://godbolt.org/z/x41Yj51a6 see if this what you're trying to do.

Yeah, I encountered a crash during the compilation process with the LLVM version I tried (19.0.0git). Additionally, I noticed that the issue persists in LLVM versions 12-15 as well. (see https://godbolt.org/z/5Wa3o9ddG)

@shafik
Copy link
Collaborator

shafik commented Apr 8, 2024

Confirmed

@shafik shafik added the confirmed Verified by a second party label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

5 participants