llvm / llvm/llvm-project

Clang Crash: Assertion NumBits <= MAX_INT_BITS failed in IntegerType::get with large ext_vector_type

Open
#165,458 2 comments 0 reactions 0 assignees View on GitHub
clang:codegen confirmed crash generated by fuzzer
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

## Compiler Explorer: https://godbolt.org/z/9fE8sP7PG
- It crashed on clang `Trunk`
- generated by fuzzer

Console:

```c
typedef _Bool bool512 __attribute__((ext_vector_type(187553262)));

bool512 b;
```

Assertion:

```console
clang: /root/llvm-project/llvm/lib/IR/Type.cpp:321: static llvm::IntegerType* llvm::IntegerType::get(llvm::LLVMContext&, unsigned int): Assertion `NumBits <= MAX_INT_BITS && "bitwidth too large"' failed.
```

Backtrace:

```console
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 -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
#0 0x0000000004224288 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4224288)
#1 0x00000000042216b4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42216b4)
#2 0x0000000004165908 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000072a639c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000072a639c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000072a639c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000072a639c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000072a639c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000072a639c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000003b93fea llvm::IntegerType::get(llvm::LLVMContext&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b93fea)
#10 0x00000000045db4a1 clang::CodeGen::CodeGenModule::EmitNullConstant(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45db4a1)
#11 0x00000000047da037 clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47da037)
#12 0x00000000047dac03 clang::CodeGen::CodeGenModule::EmitTentativeDefinition(clang::VarDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47dac03)
#13 0x0000000006acc9a6 clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6acc9a6)
#14 0x0000000006933ff5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6933ff5)
#15 0x00000000069155aa clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x69155aa)
#16 0x0000000004b6f288 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b6f288)
#17 0x0000000004e5c665 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e5c665)
#18 0x0000000004ddd63e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ddd63e)
#19 0x0000000004f5369d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f5369d)
#20 0x0000000000dcf7b0 cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdcf7b0)
#21 0x0000000000dc631a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#22 0x0000000000dc649d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#23 0x0000000004bd8649 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#24 0x0000000004165da4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4165da4)
#25 0x0000000004bd8c5f clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#26 0x0000000004b99d72 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b99d72)
#27 0x0000000004b9ad1e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b9ad1e)
#28 0x0000000004ba2455 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ba2455)
#29 0x0000000000dcbcd9 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdcbcd9)
#30 0x0000000000c7a954 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc7a954)
#31 0x000072a639c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#32 0x000072a639c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#33 0x0000000000dc5db5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdc5db5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

## Code:
```c
typedef _Bool bool512 __attribute__((ext_vector_type(187553262)));
bool512 b;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.