Issue 74189
Summary Clang-18 crash when compiled with -O2 -g -c.
Labels new issue
Assignees
Reporter iamanonymouscs
    Clang-18 with -O2 -g -c crashes on the test case.
Compiler explorer: https://godbolt.org/z/MsheKq9vb
```
$cat mutant.c
struct __attribute__((packed)) A { char c1; short a1[__INT_MAX__]; };
struct __attribute__((packed)) B { char c2; short a2[100]; };
struct S { struct A p1; struct B p2[4]; };
void bar (short int);

static void
foo (struct S *q)
{
  for (int i = 0; i < q->p1.c1; i++)
    for (int j = 0; j < q->p2[i].c2; j++)
      bar (q->p2[i].a2[j]);
}

int
main ()
{
  struct S q = {};
 q.p2[0].c2 = q.p2[1].c2 = 3;
  foo (&q);
}

$clang-18 -O2 -g -c mutant.c
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: clang-18 -O2 -g -c mutant.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'mutant.c'.
4.      Running pass 'Assignment Tracking Analysis' on function '@main'
 #0 0x00007ff48329b266 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd2b266)
 #1 0x00007ff483299170 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd29170)
 #2 0x00007ff48329a8c4 llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd2a8c4)
 #3 0x00007ff4831e8bb0 (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc78bb0)
 #4 0x00007ff48dd7c980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #5 0x00007ff4834b6e2a (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xf46e2a)
 #6 0x00007ff4834b2418 llvm::AssignmentTrackingAnalysis::runOnFunction(llvm::Function&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xf42418)
 #7 0x00007ff4833e10df llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xe710df)
 #8 0x00007ff4833e6dc3 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xe76dc3)
 #9 0x00007ff4833e17d4 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xe717d4)
#10 0x00007ff48ba7e09f clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, 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>>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1ade09f)
#11 0x00007ff48be145fe (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e745fe)
#12 0x00007ff48aa30866 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0xa90866)
#13 0x00007ff48c888645 clang::FrontendAction::Execute() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x28e8645)
#14 0x00007ff48c806cc4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x2866cc4)
#15 0x00007ff48c9031c0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x29631c0)
#16 0x0000561c05ddd837 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-18/bin/clang+0x13837)
#17 0x0000561c05dda905 (/usr/lib/llvm-18/bin/clang+0x10905)
#18 0x00007ff48c49e909 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24fe909)
#19 0x00007ff4831e894c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc7894c)
#20 0x00007ff48c49e2ae clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24fe2ae)
#21 0x00007ff48c4660f1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24c60f1)
#22 0x00007ff48c46633e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24c633e)
#23 0x00007ff48c48239c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24e239c)
#24 0x0000561c05dda25c clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-18/bin/clang+0x1025c)
#25 0x0000561c05de7f32 main (/usr/lib/llvm-18/bin/clang+0x1df32)
#26 0x00007ff48177fc87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#27 0x0000561c05dd71ea _start (/usr/lib/llvm-18/bin/clang+0xd1ea)
clang-18: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 18.0.0 (++20231018091808+48a53509e851-1~exp1~20231018091910.1571)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-18: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-18: note: diagnostic msg: /tmp/mutant-d67eef.c
clang-18: note: diagnostic msg: /tmp/mutant-d67eef.sh
clang-18: note: diagnostic msg: 

********************
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to