[llvm-bugs] [Bug 46569] New: Clang crash in clang/lib/Frontend/TextDiagnostic.cpp:1026 Assertion `StartColNo <= EndColNo && "Invalid range!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 2 19:21:01 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46569

            Bug ID: 46569
           Summary: Clang crash in
                    clang/lib/Frontend/TextDiagnostic.cpp:1026 Assertion
                    `StartColNo <= EndColNo && "Invalid range!"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: crash-on-invalid
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Hi, there.

This case, bug.cc, reduced by C-Reduce, makes clang-trunk crashed.

$cat bug.cc
typedef int a;
int b() {( a  ) & 0 ; } 

$clang++ bug.cc
bug.cc:2:17: error: cannot take the address of an rvalue of type 'int'
int b() {( a  ) & 0 ; } 
                ^ ~
bug.cc:2:10: warning: expression result unused [-Wunused-value]
clang-11:
/home/haoxin/compilers/llvm-project/clang/lib/Frontend/TextDiagnostic.cpp:1026:
void highlightRange(const clang::CharSourceRange &, unsigned int,
clang::FileID, const (anonymous namespace)::SourceColumnMap &, std::string &,
const clang::SourceManager &, const clang::LangOptions &): Assertion
`StartColNo <= EndColNo && "Invalid range!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments:
/home/haoxin/compilers/llvm-project/build/bin/clang-11 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
bug.cc -mrelocation-model static -mframe-pointer=all -fmath-errno
-fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64
-dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/home/haoxin/compilers/llvm-project/build/lib/clang/11.0.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward
-internal-isystem /usr/local/include -internal-isystem
/home/haoxin/compilers/llvm-project/build/lib/clang/11.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir
/home/haoxin/bitbucket/scg-backup-bitbucket/ice-test/0703-test/3/test_0/clang-creduce
-ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions
-fcolor-diagnostics -faddrsig -o /tmp/bug-a5ce14.o -x c++ bug.cc 
1.      bug.cc:2:23: current parser token '}'
2.      bug.cc:2:9: parsing function body 'b'
3.      bug.cc:2:9: in compound statement ('{}')
 #0 0x00000000026f36c4 PrintStackTraceSignalHandler(void*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x26f36c4)
 #1 0x00000000026f12be llvm::sys::RunSignalHandlers()
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x26f12be)
 #2 0x00000000026f39e5 SignalHandler(int)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x26f39e5)
 #3 0x00007f34bd293890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f34bbcf1e97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f34bbcf3801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f34bbce339a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f34bbce3412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x0000000002f64f89
clang::TextDiagnostic::emitSnippetAndCaret(clang::FullSourceLoc,
clang::DiagnosticsEngine::Level,
llvm::SmallVectorImpl<clang::CharSourceRange>&,
llvm::ArrayRef<clang::FixItHint>)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2f64f89)
 #9 0x0000000002f58cf5
clang::DiagnosticRenderer::emitDiagnostic(clang::FullSourceLoc,
clang::DiagnosticsEngine::Level, llvm::StringRef,
llvm::ArrayRef<clang::CharSourceRange>, llvm::ArrayRef<clang::FixItHint>,
llvm::PointerUnion<clang::Diagnostic const*, clang::StoredDiagnostic const*>)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2f58cf5)
#10 0x0000000002f0b1e4
clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level,
clang::Diagnostic const&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2f0b1e4)
#11 0x00000000028d76ab
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x28d76ab)
#12 0x00000000028d19fa clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x28d19fa)
#13 0x0000000003ee212d clang::Sema::EmitCurrentDiagnostic(unsigned int)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3ee212d)
#14 0x00000000041dc781 clang::Sema::DiagRuntimeBehavior(clang::SourceLocation,
llvm::ArrayRef<clang::Stmt const*>, clang::PartialDiagnostic const&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x41dc781)
#15 0x000000000418041c clang::Sema::DiagRuntimeBehavior(clang::SourceLocation,
clang::Stmt const*, clang::PartialDiagnostic const&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x418041c)
#16 0x00000000044b687d clang::Sema::DiagnoseUnusedExprResult(clang::Stmt
const*) (/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x44b687d)
#17 0x00000000042992ff clang::Sema::ActOnFinishFullExpr(clang::Expr*,
clang::SourceLocation, bool, bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x42992ff)
#18 0x00000000044b5281
clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>, bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x44b5281)
#19 0x0000000003e8ebaa
clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e8ebaa)
#20 0x0000000003e8d303
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e8d303)
#21 0x0000000003e8cd12
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e8cd12)
#22 0x0000000003e95081 clang::Parser::ParseCompoundStatementBody(bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e95081)
#23 0x0000000003e95e50 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e95e50)
#24 0x0000000003df073a
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3df073a)
#25 0x0000000003e0b792 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e0b792)
#26 0x0000000003def8fc
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3def8fc)
#27 0x0000000003def395
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3def395)
#28 0x0000000003dee1bf
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3dee1bf)
#29 0x0000000003dec28d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3dec28d)
#30 0x0000000003de770d clang::ParseAST(clang::Sema&, bool, bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3de770d)
#31 0x0000000002ebc3f3 clang::FrontendAction::Execute()
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2ebc3f3)
#32 0x0000000002e539c3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2e539c3)
#33 0x0000000002f67532
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2f67532)
#34 0x000000000095d060 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95d060)
#35 0x000000000095b12c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95b12c)
#36 0x000000000095addf main
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95addf)
#37 0x00007f34bbcd4b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#38 0x0000000000957eba _start
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x957eba)
clang-11: error: unable to execute command: Aborted (core dumped)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.0.0 (https://github.com/llvm/llvm-project
b9306fd042ce1c11d84f05d2124dfdc65b8331fe)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-project/build/bin
clang-11: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-11: note: diagnostic msg: /tmp/bug-5ffb7c.cpp
clang-11: note: diagnostic msg: /tmp/bug-5ffb7c.sh
clang-11: note: diagnostic msg: 

********************

$clang++ -v
clang version 11.0.0 (https://github.com/llvm/llvm-project
b9306fd042ce1c11d84f05d2124dfdc65b8331fe)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64

This case may be similar to bug 12818 (in a valid code), but I guess they are
not the same.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200703/ee438a68/attachment.html>


More information about the llvm-bugs mailing list