[llvm-bugs] [Bug 51795] New: Clang reports error in backend when using stack protector and SVE

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 8 09:18:16 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51795

            Bug ID: 51795
           Summary: Clang reports error in backend when using stack
                    protector and SVE
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: branislav.rankov at arm.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 25244
  --> https://bugs.llvm.org/attachment.cgi?id=25244&action=edit
preprocessed source

When compiling a simple example that has local SVE variables and stack
protector is enabled it reports and error in the backend.

The command to reproduce it simple:
../../out_clang/bin/clang --target=aarch64-linux-gnu -march=armv8+sve -c 
-fstack-protector-strong ./test/CodeGen/arm-sve-vector-bits-vscale-range.c



fatal error: error in backend: Invalid size request on a scalable vector.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: out_clang/bin/clang --target=aarch64-linux-gnu
-march=armv8+sve -c -fstack-protector-strong
llvm-project/clang/test/CodeGen/aarch64-sve.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module
'llvm-project/clang/test/CodeGen/aarch64-sve.c'.
4.      Running pass 'Insert stack protectors' on function '@test_locals'
 #0 0x0000559f058b8eee llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/work/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:0
 #1 0x0000559f058b8fa5 PrintStackTraceSignalHandler(void*)
/work/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:0
 #2 0x0000559f058b6c59 llvm::sys::RunSignalHandlers()
/work/llvm/llvm-project/llvm/lib/Support/Signals.cpp:97:0
 #3 0x0000559f058b8748 llvm::sys::CleanupOnSignal(unsigned long)
/work/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:361:0
 #4 0x0000559f057e51a8 (anonymous
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long)
/work/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:76:0
 #5 0x0000559f057e5926 llvm::CrashRecoveryContext::HandleExit(int)
/work/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:442:0
 #6 0x0000559f058b20f7 llvm::sys::Process::Exit(int, bool)
/work/llvm/llvm-project/llvm/lib/Support/Process.cpp:99:0
 #7 0x0000559f0258d388 ensureStackAddressSpace()
/work/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:132:0
 #8 0x0000559f057ee2ae llvm::report_fatal_error(llvm::Twine const&, bool)
/work/llvm/llvm-project/llvm/lib/Support/ErrorHandling.cpp:108:0
 #9 0x0000559f057ee151
llvm::report_fatal_error(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, bool)
/work/llvm/llvm-project/llvm/lib/Support/ErrorHandling.cpp:86:0
#10 0x0000559f05846e31 llvm::reportInvalidSizeRequest(char const*)
/work/llvm/llvm-project/llvm/lib/Support/TypeSize.cpp:47:0
#11 0x0000559f05846e5c llvm::TypeSize::operator unsigned long() const
/work/llvm/llvm-project/llvm/lib/Support/TypeSize.cpp:54:0
#12 0x0000559f049470a8 llvm::StackProtector::RequiresStackProtector()
/work/llvm/llvm-project/llvm/lib/CodeGen/StackProtector.cpp:354:0
#13 0x0000559f04945c41 llvm::StackProtector::runOnFunction(llvm::Function&)
/work/llvm/llvm-project/llvm/lib/CodeGen/StackProtector.cpp:101:0
#14 0x0000559f04ce802a llvm::FPPassManager::runOnFunction(llvm::Function&)
/work/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1439:0
#15 0x0000559f04ce82d3 llvm::FPPassManager::runOnModule(llvm::Module&)
/work/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1485:0
#16 0x0000559f04ce86fb (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
/work/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1554:0
#17 0x0000559f04ce37bb llvm::legacy::PassManagerImpl::run(llvm::Module&)
/work/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:542:0
#18 0x0000559f04ce8f85 llvm::legacy::PassManager::run(llvm::Module&)
/work/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1682:0
#19 0x0000559f05cfcfd8 (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/work/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1500:0
#20 0x0000559f05cfe196 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef,
llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/work/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1661:0
#21 0x0000559f070678bc
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/work/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:334:0
#22 0x0000559f08b2e5e2 clang::ParseAST(clang::Sema&, bool, bool)
/work/llvm/llvm-project/clang/lib/Parse/ParseAST.cpp:178:0
#23 0x0000559f066659a1 clang::ASTFrontendAction::ExecuteAction()
/work/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1058:0
#24 0x0000559f070641cc clang::CodeGenAction::ExecuteAction()
/work/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1072:0
#25 0x0000559f0666526a clang::FrontendAction::Execute()
/work/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:955:0
#26 0x0000559f065a3f52
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/work/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:974:0
#27 0x0000559f067fd11e
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/work/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:0
#28 0x0000559f0258dc28 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /work/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:246:0
#29 0x0000559f02582115 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/work/llvm/llvm-project/clang/tools/driver/driver.cpp:317:0
#30 0x0000559f06480c49
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'()::operator()() const
/work/llvm/llvm-project/clang/lib/Driver/Job.cpp:405:0
#31 0x0000559f0648125a 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)
/work/llvm/llvm-project/llvm/include/llvm/ADT/STLExtras.h:178:0
#32 0x0000559f057d9c52 llvm::function_ref<void ()>::operator()() const
/work/llvm/llvm-project/llvm/include/llvm/ADT/STLExtras.h:200:0
#33 0x0000559f057e58c3
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
/work/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426:0
#34 0x0000559f06480e54
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const
/work/llvm/llvm-project/clang/lib/Driver/Job.cpp:405:0
#35 0x0000559f064322b0
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
/work/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:196:0
#36 0x0000559f0643262c
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
/work/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:249:0
#37 0x0000559f0644208a
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
/work/llvm/llvm-project/clang/lib/Driver/Driver.cpp:1557:0
#38 0x0000559f02583251 main
/work/llvm/llvm-project/clang/tools/driver/driver.cpp:489:0
#39 0x00007f0c2c5ffbf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#40 0x0000559f0258088a _start (out_clang/bin/clang+0x321188a)
clang-14: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
2706b1a6e2dfe79a5c17c7d6f99401d386a9355b)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work/llvm/out_clang/bin


Run script:

# Crash reproducer for clang version 14.0.0
(https://github.com/llvm/llvm-project.git
2706b1a6e2dfe79a5c17c7d6f99401d386a9355b)
# Driver args: "--target=aarch64-linux-gnu" "-march=armv8+sve" "-c"
"-fstack-protector-strong" "llvm-project/clang/test/CodeGen/aarch64-sve.c"
# Original command:  "/work/llvm/out_clang/bin/clang-14" "-cc1" "-triple"
"aarch64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "--mrelax-relocations"
"-disable-free" "-main-file-name" "aarch64-sve.c" "-mrelocation-model" "static"
"-mframe-pointer=non-leaf" "-fmath-errno" "-fno-rounding-math"
"-mconstructor-aliases" "-munwind-tables" "-target-cpu" "generic"
"-target-feature" "+neon" "-target-feature" "+sve" "-target-abi" "aapcs"
"-fallow-half-arguments-and-returns" "-debugger-tuning=gdb"
"-fcoverage-compilation-dir=/work/llvm" "-resource-dir"
"/work/llvm/out_clang/lib/clang/14.0.0" "-internal-isystem"
"/work/llvm/out_clang/lib/clang/14.0.0/include" "-internal-isystem"
"/usr/local/include" "-internal-isystem"
"/usr/lib/gcc-cross/aarch64-linux-gnu/7.5.0/../../../../aarch64-linux-gnu/include"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-fdebug-compilation-dir=/work/llvm" "-ferror-limit" "19"
"-stack-protector" "2" "-fno-signed-char" "-fgnuc-version=4.2.1" "-faddrsig"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "aarch64-sve.o" "-x" "c"
"llvm-project/clang/test/CodeGen/aarch64-sve.c"
 "/work/llvm/out_clang/bin/clang-14" "-cc1" "-triple"
"aarch64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "--mrelax-relocations"
"-disable-free" "-main-file-name" "aarch64-sve.c" "-mrelocation-model" "static"
"-mframe-pointer=non-leaf" "-fmath-errno" "-fno-rounding-math"
"-mconstructor-aliases" "-munwind-tables" "-target-cpu" "generic"
"-target-feature" "+neon" "-target-feature" "+sve" "-target-abi" "aapcs"
"-fallow-half-arguments-and-returns" "-debugger-tuning=gdb"
"-fcoverage-compilation-dir=/work/llvm" "-fdebug-compilation-dir=/work/llvm"
"-ferror-limit" "19" "-stack-protector" "2" "-fno-signed-char"
"-fgnuc-version=4.2.1" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c"
"aarch64-sve-ce8d7f.c"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210908/006a6575/attachment-0001.html>


More information about the llvm-bugs mailing list