clang-format crashes in BreakableBlockComment
| Bugzilla Link | 22920 |
| Resolution | DUPLICATE |
| Resolved on | Apr 01, 2015 17:40 |
| Version | unspecified |
| OS | Linux |
| Attachments | reproducer |
| CC | @KernelAddress,@kcc |
Extended Description
Revision 232356.
When I run clang-format -style=google on the attached file, it crashes with:
clang-format: ../tools/clang/lib/Format/BreakableToken.cpp:257: clang::format::BreakableBlockComment::BreakableBlockComment(const clang::format::FormatToken &, unsigned int, unsigned int, unsigned int, bool, bool, encoding::Encoding, const clang::format::FormatStyle &): Assertion `TokenText.startswith("/") && TokenText.endswith("/")' failed. #0 0x44bbd1 backtrace /ssd/src/llvm/build/../projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:3010:0 #1 0x573a35 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /ssd/src/llvm1/build/../lib/Support/Unix/Signals.inc:424:15 #2 0x57ab08 SignalHandler(int) /ssd/src/llvm1/build/../lib/Support/Unix/Signals.inc:199:3 #3 0x7f19f1213340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340) #4 0x7f19f03bccc9 gsignal /build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0 #5 0x7f19f03c00d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0 #6 0x7f19f03b5b86 __assert_fail_base /build/buildd/eglibc-2.19/assert/assert.c:92:0 #7 0x7f19f03b5c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32) #8 0x79ca0a clang::format::BreakableBlockComment::BreakableBlockComment(clang::format::FormatToken const&, unsigned int, unsigned int, unsigned int, bool, bool, clang::format::encoding::Encoding, clang::format::FormatStyle const&) /ssd/src/llvm1/build/../tools/clang/lib/Format/BreakableToken.cpp:258:3 #9 0x78776d clang::format::ContinuationIndenter::breakProtrudingToken(clang::format::FormatToken const&, clang::format::LineState&, bool) /ssd/src/llvm1/build/../tools/clang/lib/Format/ContinuationIndenter.cpp:979:21 #10 0x76ad62 clang::format::ContinuationIndenter::moveStateToNextToken(clang::format::LineState&, bool, bool) /ssd/src/llvm1/build/../tools/clang/lib/Format/ContinuationIndenter.cpp:693:22 #11 0x777af3 clang::format::ContinuationIndenter::addTokenToState(clang::format::LineState&, bool, bool, unsigned int) /ssd/src/llvm1/build/../tools/clang/lib/Format/ContinuationIndenter.cpp:274:10 #12 0x71c3a1 clang::format::UnwrappedLineFormatter::addNextStateToQueue(unsigned int, clang::format::UnwrappedLineFormatter::StateNode*, bool, unsigned int*, std::priority_queue<std::pair<std::pair<unsigned int, unsigned int>, clang::format::UnwrappedLineFormatter::StateNode*>, std::vector<std::pair<std::pair<unsigned int, unsigned int>, clang::format::UnwrappedLineFormatter::StateNode*>, std::allocator<std::pair<std::pair<unsigned int, unsigned int>, clang::format::UnwrappedLineFormatter::StateNode*> > >, std::greater<std::pair<std::pair<unsigned int, unsigned int>, clang::format::UnwrappedLineFormatter::StateNode*> > >*) /ssd/src/llvm1/build/../tools/clang/lib/Format/UnwrappedLineFormatter.cpp:666:11 #13 0x719ee3 clang::format::UnwrappedLineFormatter::analyzeSolutionSpace(clang::format::LineState&, bool) /ssd/src/llvm1/build/../tools/clang/lib/Format/UnwrappedLineFormatter.cpp:594:7 #14 0x710b2c format /ssd/src/llvm1/build/../tools/clang/lib/Format/UnwrappedLineFormatter.cpp:485:10 #15 0x710b2c clang::format::UnwrappedLineFormatter::format(llvm::SmallVectorImplclang::format::AnnotatedLine* const&, bool, int, bool) /ssd/src/llvm1/build/../tools/clang/lib/Format/UnwrappedLineFormatter.cpp:434:0 #16 0x6804fb format /ssd/src/llvm1/build/../tools/clang/lib/Format/Format.cpp:1239:12 #17 0x6804fb format /ssd/src/llvm1/build/../tools/clang/lib/Format/Format.cpp:1202:0 #18 0x6804fb clang::format::reformat(clang::format::FormatStyle const&, clang::SourceManager&, clang::FileID, llvm::ArrayRefclang::CharSourceRange) /ssd/src/llvm1/build/../tools/clang/lib/Format/Format.cpp:1470:0 #19 0x4deca4 getValue /ssd/src/llvm1/build/../include/llvm/Support/CommandLine.h:1172:38 #20 0x4deca4 operator bool /ssd/src/llvm1/build/../include/llvm/Support/CommandLine.h:1176:0 #21 0x4deca4 clang::format::format(llvm::StringRef) /ssd/src/llvm1/build/../tools/clang/tools/clang-format/ClangFormat.cpp:229:0 #22 0x4dc28c main /ssd/src/llvm1/build/../tools/clang/tools/clang-format/ClangFormat.cpp:303:13 #23 0x7f19f03a7ec5 __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:321:0 #24 0x420e1a _start (/ssd/src/llvm1/build/bin/clang-format+0x420e1a)
mentioned in issue llvm/llvm-bugzilla-archive#23052
Let's track the clang-format fuzzing bugs in one place. https://llvm.org/bugs/show_bug.cgi?id=23052#c4
*** This bug has been marked as a duplicate of bug llvm/llvm-bugzilla-archive#23052 ***