| Issue |
202340
|
| Summary |
Internal assertion failed on unitialised variable passed as alloca argument
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
lmaltsis
|
```c
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
uint32_t a() {
uint32_t b;
for (uint32_t c = 0; c < 2; c++)
b |= c;
return b;
}
int d() {
char buf[2];
int32_t e = a();
void *f = alloca(e);
snprintf(buf, 2, "%s", (char *)f);
return 0;
}
```
It seems like the function call of a() and the bounded for-loop are required to confuse clang sufficiently.
https://godbolt.org/z/WTTE8Perh
Triggers on https://github.com/llvm/llvm-project/commit/9b4b9de0319b63ff56dd157b1d12465f206681f6
```sh
clang: /root/llvm-project/llvm/include/llvm/CodeGen/MachineFrameInfo.h:556: int64_t llvm::MachineFrameInfo::getObjectOffset(int) const: Assertion `!isDeadObjectIndex(ObjectIdx) && "Getting frame offset for a dead object?"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -g -o /app/output.s -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 <source>
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@d'
#0 0x000000000436a148 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x436a148)
#1 0x0000000004366f84 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4366f84)
#2 0x00000000043675a4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43675a4)
#3 0x00000000042a38b8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007fafafc45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007fafafc9eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
#6 0x00007fafafc4527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007fafafc288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00007fafafc2881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x00007fafafc3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000000002c476bb llvm::X86FrameLowering::getFrameIndexReference(llvm::MachineFunction const&, int, llvm::Register&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2c476bb)
#11 0x0000000003796010 (anonymous namespace)::PEIImpl::replaceFrameIndexDebugInstr(llvm::MachineFunction&, llvm::MachineInstr&, unsigned int, int) (.isra.0) PrologEpilogInserter.cpp:0:0
#12 0x000000000379e669 (anonymous namespace)::PEIImpl::run(llvm::MachineFunction&) (.constprop.0) PrologEpilogInserter.cpp:0:0
#13 0x000000000379fa00 (anonymous namespace)::PEILegacy::runOnMachineFunction(llvm::MachineFunction&) PrologEpilogInserter.cpp:0:0
#14 0x0000000003615369 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000003c52d9c llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c52d9c)
#16 0x0000000003c53091 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c53091)
#17 0x0000000003c5394d llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c5394d)
#18 0x000000000478d8df clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x478d8df)
#19 0x0000000004e56117 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e56117)
#20 0x0000000006c0cf2c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6c0cf2c)
#21 0x0000000004e56568 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e56568)
#22 0x000000000518b238 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x518b238)
#23 0x0000000005108a6d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5108a6d)
#24 0x0000000005289ead clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5289ead)
#25 0x0000000000e2006b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xe2006b)
#26 0x0000000000e168ba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#27 0x0000000000e16a3d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#28 0x0000000004ec8929 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
#29 0x00000000042a3cf4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42a3cf4)
#30 0x0000000004ec8f76 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
#31 0x0000000004e85a82 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e85a82)
#32 0x0000000004e86a2e 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+0x4e86a2e)
#33 0x0000000004e8ec35 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e8ec35)
#34 0x0000000000e1c384 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xe1c384)
#35 0x0000000000cc032a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcc032a)
#36 0x00007fafafc2a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#37 0x00007fafafc2a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#38 0x0000000000e16355 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xe16355)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs