Issue 107703
Summary [Clang] Assertion `!Traits::stopLess(b, a) && "Invalid interval"' failed.
Labels clang
Assignees
Reporter yijan4845
    Compiler Explorer: [https://godbolt.org/z/7rMGf5q4E](https://godbolt.org/z/7rMGf5q4E)

Attempting to compile the following valid program with Clang Assertion Trunk:
```c
#define ASIZE 0x80000000UL
extern void abort (void);
int __attribute__((noinline))
foo (const char *s) {
  if (s[0] != 'a')
    abort ();
  return 0;
}
int __attribute__((noinline))
baz(long i) {
    char s[ASIZE];
    s[0] = 'a'; 
    s[0] = 'a';
    foo(s);
    return 0;
}
```

Stack dump:

```
clang-20: /root/llvm-project/llvm/include/llvm/ADT/IntervalMap.h:633: unsigned int llvm::IntervalMapImpl::LeafNode<KeyT, ValT, N, Traits>::insertFrom(unsigned int&, unsigned int, KeyT, KeyT, ValT) [with KeyT = unsigned int; ValT = unsigned int; unsigned int N = 16; Traits = llvm::IntervalMapHalfOpenInfo<unsigned int>]: Assertion `!Traits::stopLess(b, a) && "Invalid interval"' failed.
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-20240907/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir /app/output.s- -disable-free -clear-ast-before-backend -main-file-name example.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20240907/lib/clang/20 -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20240907/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-06c9d9.o -x c <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'Assignment Tracking Analysis' on function '@baz'
 #0 0x0000000003b24fa8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3b24fa8)
 #1 0x0000000003b226ec SignalHandler(int) Signals.cpp:0:0
 #2 0x000071f308842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000071f3088969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x000071f308842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x000071f3088287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x000071f30882871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x000071f308839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x00000000032fa468 llvm::IntervalMapImpl::LeafNode<unsigned int, unsigned int, 16u, llvm::IntervalMapHalfOpenInfo<unsigned int>>::insertFrom(unsigned int&, unsigned int, unsigned int, unsigned int, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x32fa468)
 #9 0x0000000003312aca llvm::IntervalMap<unsigned int, unsigned int, 16u, llvm::IntervalMapHalfOpenInfo<unsigned int>>::insert(unsigned int, unsigned int, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3312aca)
#10 0x0000000003315239 (anonymous namespace)::MemLocFragmentFill::addDef(llvm::VarLocInfo const&, llvm::PointerUnion<llvm::Instruction const*, llvm::DbgRecord const*>, llvm::BasicBlock&, llvm::DenseMap<unsigned int, llvm::IntervalMap<unsigned int, unsigned int, 16u, llvm::IntervalMapHalfOpenInfo<unsigned int>>, llvm::DenseMapInfo<unsigned int, void>, llvm::detail::DenseMapPair<unsigned int, llvm::IntervalMap<unsigned int, unsigned int, 16u, llvm::IntervalMapHalfOpenInfo<unsigned int>>>>&) AssignmentTrackingAnalysis.cpp:0:0
#11 0x00000000033173e9 (anonymous namespace)::MemLocFragmentFill::run(FunctionVarLocsBuilder*) AssignmentTrackingAnalysis.cpp:0:0
#12 0x000000000331a0a8 analyzeFunction(llvm::Function&, llvm::DataLayout const&, FunctionVarLocsBuilder*) AssignmentTrackingAnalysis.cpp:0:0
#13 0x000000000331b057 llvm::AssignmentTrackingAnalysis::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x331b057)
#14 0x0000000003494a60 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3494a60)
#15 0x0000000003494e11 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3494e11)
#16 0x00000000034956c7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x34956c7)
#17 0x0000000003dd1605 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>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3dd1605)
#18 0x000000000446ef8e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x446ef8e)
#19 0x00000000065ae3fc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x65ae3fc)
#20 0x000000000446f378 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x446f378)
#21 0x00000000047012b9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x47012b9)
#22 0x0000000004684b6e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x4684b6e)
#23 0x00000000047ea6de clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x47ea6de)
#24 0x0000000000cb8fdf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0xcb8fdf)
#25 0x0000000000cb222a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x0000000000cb5b5e clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0xcb5b5e)
#27 0x0000000000b88c84 main (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0xb88c84)
#28 0x000071f308829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#29 0x000071f308829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#30 0x0000000000cb1cde _start (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0xcb1cde)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)

```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to