llvm / llvm/llvm-project

crash on error handler in clang since version 11

Open
#214,666 1 comment 0 reactions 0 assignees View on GitHub
backend:X86 confirmed crash-on-valid llvm:SelectionDAG
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

## Assertion

```
No assertion
fatal error: error in backend: SmallVector unable to grow. Requested capacity (18446744073709518848) is larger than maximum value for size type (4294967295)
```

## Stack dump

```
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics
1. parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module ''.
4. Running pass 'X86 DAG->DAG Instruction Selection' on function '@f'
#0 0x0000000003cdf608 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3cdf608)
#1 0x0000000003cdcf4c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3cdcf4c)
#2 0x0000000003c211d3 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c211d3)
#3 0x0000000003cd489e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3cd489e)
#4 0x0000000000dea3fb LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
#5 0x0000000003c298f3 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c298f3)
#6 0x0000000003c5ce46 report_size_overflow(unsigned long, unsigned long) (.constprop.0) SmallVector.cpp:0:0
#7 0x0000000003c5cfc9 llvm::SmallVectorBase::grow_pod(void*, unsigned long, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c5cfc9)
#8 0x00000000053a63cf llvm::DAGTypeLegalizer::SplitVecRes_BUILD_VECTOR(llvm::SDNode*, llvm::SDValue&, llvm::SDValue&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x53a63cf)
#9 0x00000000053eb992 llvm::DAGTypeLegalizer::SplitVectorResult(llvm::SDNode*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x53eb992)
#10 0x000000000538cfac llvm::DAGTypeLegalizer::run() (/opt/compiler-explorer/clang-trunk/bin/clang+0x538cfac)
#11 0x000000000538d4a4 llvm::SelectionDAG::LegalizeTypes() (/opt/compiler-explorer/clang-trunk/bin/clang+0x538d4a4)
#12 0x00000000052f5752 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+0x52f5752)
#13 0x00000000052f7b7f llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x52f7b7f)
#14 0x00000000052f95a5 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x52f95a5)
#15 0x00000000052f4ae1 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x52f4ae1)
#16 0x0000000003120c45 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3120c45)
#17 0x0000000003637862 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3637862)
#18 0x0000000003637c71 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3637c71)
#19 0x000000000363874a llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x363874a)
#20 0x000000000405ec5f (anonymous namespace)::EmitAssemblyHelper::TimeCodegenPasses(llvm::function_ref) (.isra.0) BackendUtil.cpp:0:0
#21 0x0000000004070e9a clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::unique_ptr>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4070e9a)
#22 0x00000000046b5072 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x46b5072)
#23 0x000000000631491c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x631491c)
#24 0x00000000046b5aa5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x46b5aa5)
#25 0x00000000049eac51 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x49eac51)
#26 0x000000000497ba85 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x497ba85)
#27 0x0000000004abdc9b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4abdc9b)
#28 0x0000000000dec498 cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xdec498)
#29 0x0000000000de430b ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#30 0x0000000000de43ad int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#31 0x0000000004731589 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#32 0x0000000003c210d3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c210d3)
#33 0x0000000004731fcd clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#34 0x00000000046ec6e2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x46ec6e2)
#35 0x00000000046f0a45 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x46f0a45)
#36 0x00000000046fbaec clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x46fbaec)
#37 0x0000000000de8e41 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xde8e41)
#38 0x0000000000d0d14a main (/opt/compiler-explorer/clang-trunk/bin/clang+0xd0d14a)
#39 0x000072e239e2a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#40 0x000072e239e2a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#41 0x0000000000de3db5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xde3db5)

```

## Program

```c

typedef unsigned vec __attribute__ ((vector_size (65535 * sizeof (int))));

void
f (vec *x)
{
*x = (*x << 5) << 0;
}

```

## To reproduce:

https://godbolt.org/z/6nYWaj9Pf

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the C example with the Godbolt link and inspect the stack path through llvm::DAGTypeLegalizer::SplitVecRes_BUILD_VECTOR, llvm::SmallVectorBase::grow_pod, and SmallVector.cpp. Compare the error-handler behavior when compiling the oversized vector expression; done means this testcase no longer crashes with the SmallVector capacity error and has a suitable compiler diagnostic or safe failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.