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

sparc64 segfault with function returning an empty struct #40784

Open
arndb mannequin opened this issue Apr 9, 2019 · 2 comments
Open

sparc64 segfault with function returning an empty struct #40784

arndb mannequin opened this issue Apr 9, 2019 · 2 comments
Labels
backend:Sparc bugzilla Issues migrated from bugzilla clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@arndb
Copy link
Mannequin

arndb mannequin commented Apr 9, 2019

Bugzilla Link 41439
Version 8.0
OS Linux
Blocks #4440
CC @nickdesaulniers

Extended Description

Attempting to build a sparc64 linux kernel with clang, I ran into a segmentation fault compiling mm/mmap.c. Reduced the test case to

struct vm_userfaultfd_ctx {
} fn1(struct vm_userfaultfd_ctx p1) {
return p1;
}

$ clang-9 -cc1 mmap.c -triple sparc64-unknown-linux-gnu -S
Stack dump:
0. Program arguments: clang-9 -cc1 mmap-f2e46f.c -triple sparc64-unknown-linux-gnu -S

  1. parser at end of file
  2. mmap-f2e46f.c:2:3: LLVM IR generation of declaration 'fn1'
  3. mmap-f2e46f.c:2:3: Generating code for declaration 'fn1'
    #​0 0x00007f8be972b97f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x96d97f)
    #​1 0x00007f8be9729dd0 llvm::sys::RunSignalHandlers() (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x96bdd0)
    #​2 0x00007f8be972bd88 (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x96dd88)
    #​3 0x00007f8bec979390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
    #​4 0x000000000087982d (clang-9+0x87982d)
    #​5 0x000000000076836a (clang-9+0x76836a)
    #​6 0x000000000076984f (clang-9+0x76984f)
    #​7 0x0000000000780b8b (clang-9+0x780b8b)
    #​8 0x000000000077a90b (clang-9+0x77a90b)
    #​9 0x0000000000783072 (clang-9+0x783072)
    #​10 0x0000000000d70c3f (clang-9+0xd70c3f)
    #​11 0x0000000000d6e572 (clang-9+0xd6e572)
    #​12 0x00000000011f2c33 (clang-9+0x11f2c33)
    #​13 0x0000000000af751f (clang-9+0xaf751f)
    #​14 0x0000000000ab7878 (clang-9+0xab7878)
    #​15 0x0000000000b7c895 (clang-9+0xb7c895)
    #​16 0x00000000006b140c (clang-9+0x6b140c)
    #​17 0x00000000006af97f (clang-9+0x6af97f)
    #​18 0x00007f8be8167830 __libc_start_main /build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:325:0
    #​19 0x00000000006ad0d9 (clang-9+0x6ad0d9)
    Segmentation fault (core dumped)
@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@Endilll
Copy link
Contributor

Endilll commented Sep 11, 2023

Still crashing as of post-17 trunk: https://godbolt.org/z/YTM68b4Yo

clang++: /root/llvm-project/llvm/include/llvm/IR/Function.h:795:
llvm::Argument* llvm::Function::getArg(unsigned int) const:
Assertion `i < NumArgs && "getArg() out of range!"' 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 -x c -Wno-implicit-int -Wno-implicit-function-declaration -target sparc64-unknown-linux-gnu <source>
1.	<eof> parser at end of file
2.	<source>:2:3: LLVM IR generation of declaration 'fn1'
3.	<source>:2:3: Generating code for declaration 'fn1'
 #0 0x00000000036aeb98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36aeb98)
 #1 0x00000000036ac85c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36ac85c)
 #2 0x00000000035f5c88 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f27702d9420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f276fd9c00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f276fd7b859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f276fd7b729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f276fd8cfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x0000000003d3bfdb clang::CodeGen::CodeGenFunction::EmitFunctionProlog(clang::CodeGen::CGFunctionInfo const&, llvm::Function*, clang::CodeGen::FunctionArgList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d3bfdb)
 #9 0x0000000003a3bb54 clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a3bb54)
#10 0x0000000003a40ba1 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a40ba1)
#11 0x0000000003aa1fc3 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3aa1fc3)
#12 0x0000000003a9d0b5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9d0b5)
#13 0x0000000003a9d67b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9d67b)
#14 0x0000000003aa6af3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#15 0x00000000049117b6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#16 0x00000000049023c8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49023c8)
#17 0x0000000005e03784 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e03784)
#18 0x000000000490e668 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x490e668)
#19 0x0000000004176d59 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4176d59)
#20 0x00000000040f6f7e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40f6f7e)
#21 0x0000000004254fce clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4254fce)
#22 0x0000000000bd6e70 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd6e70)
#23 0x0000000000bcf09a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#24 0x0000000003f582e9 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
#25 0x00000000035f6134 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35f6134)
#26 0x0000000003f588df 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
#27 0x0000000003f20c65 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f20c65)
#28 0x0000000003f216cd 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+++0x3f216cd)
#29 0x0000000003f295f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f295f5)
#30 0x0000000000bd4c7c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd4c7c)
#31 0x0000000000ad1481 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xad1481)
#32 0x00007f276fd7d083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x0000000000bceb7e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbceb7e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)

@Endilll Endilll added backend:Sparc clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] labels Sep 11, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 11, 2023

@llvm/issue-subscribers-clang-codegen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:Sparc bugzilla Issues migrated from bugzilla clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

2 participants