Created attachment 12353 [details] The file that causes the crash Clang crashes on applying coding standards to a file named StructureTreeCache.cpp (in attachment). OS Windows 8 The error: Assertion failed: NewRemainingTokenColumns < RemainingTokenColumns, file ..\tools\clang\lib\Format\ContinuationIndenter.cpp, line 876 Traceback (most recent call last): File "apply-cs.py", line 54, in <module> subprocess.check_call([CLANG_FORMAT,'-i',f,'-style=file']) File "C:\Python27\lib\subprocess.py", line 511, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['D:\\git-root\\qt\\cmbuild\\bin\\win32_clang-format', '-i', 'D:\\git-root\\beetrunk\\beecore\\src\\server\\module\\Bee\\Cache\\StructureTreeCache.cpp', '-style=file']' returned non-zero exit status -1073740791 ####################### using the following config data: # uncomment the following once clang 3.5 is out Language: Cpp CommentPragmas: '^ IWYU pragma:' Standard: Cpp03 TabWidth: 4 UseTab: Always BreakBeforeBraces: Allman # indentation rules NamespaceIndentation: None ContinuationIndentWidth: 4 IndentWidth: 4 IndentCaseLabels: true # spaces in angles and brackets SpacesInParentheses: true SpacesInAngles: false SpaceInEmptyParentheses: false SpacesInCStyleCastParentheses: false SpaceBeforeAssignmentOperators: true SpacesBeforeTrailingComments: 1 SpaceBeforeParens: Never SpaceInEmptyParentheses: false SpacesInAngles: false # class/constructor related AccessModifierOffset: -4 ConstructorInitializerIndentWidth: 4 ConstructorInitializerAllOnOneLineOrOnePerLine: false BreakConstructorInitializersBeforeComma: true # Function related formatting IndentFunctionDeclarationAfterType: true BinPackParameters: false #AllowShortFunctionsOnASingleLine: true # control statement formatting AllowShortLoopsOnASingleLine: false BreakBeforeBinaryOperators: false BreakBeforeTernaryOperators: true AlignEscapedNewlinesLeft: false AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: false AllowShortIfStatementsOnASingleLine: false AlwaysBreakTemplateDeclarations: true AlwaysBreakBeforeMultilineStrings: false ColumnLimit: 120 DerivePointerBinding: false ExperimentalAutoDetectBinPacking: false MaxEmptyLinesToKeep: 1 ObjCSpaceBeforeProtocolList: true PenaltyBreakBeforeFirstCallParameter: 0 PenaltyBreakComment: 300 PenaltyBreakString: 1000 PenaltyBreakFirstLessLess: 120 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerBindsToType: true Cpp11BracedListStyle: false
I can reproduce this, it seems to assert in breakProtrudingToken(). Alex, can you take a look?
I don't see any crashes on the attached file using the style quoted here (and also the llvm style). I build clang-format from r205758. $ clang-format StructureTreeCache.cpp -style=llvm ... [formatted output] $ cat .clang-format # uncomment the following once clang 3.5 is out Language: Cpp CommentPragmas: '^ IWYU pragma:' Standard: Cpp03 TabWidth: 4 UseTab: Always BreakBeforeBraces: Allman ... $ clang-format StructureTreeCache.cpp -style=file ... [formatted output] Daniel, how do you reproduce the issue and what symptoms do you observe (the mostly interesting being the stack trace)?
With clang-format built from head: $ bin/clang-format ~/Downloads/StructureTreeCache.cpp Can't find usable .clang-format, using LLVM style clang-format: /usr/local/google/clang/llvm/tools/clang/lib/Format/ContinuationIndenter.cpp:941: unsigned int clang::format::ContinuationIndenter::breakProtrudingToken(const clang::format::FormatToken &, clang::format::LineState &, bool): Assertion `NewRemainingTokenColumns < RemainingTokenColumns' failed. ...
In case it helps, I can also reproduce the issue with clang SVN rev 205846 (via git mirror 2f53df4e2), on Mac OS X 10.8.5. I am using a Debug+Assert build, and get this: clang-format ~/Downloads/StructureTreeCache.cpp Can't find usable .clang-format, using LLVM style Assertion failed: (NewRemainingTokenColumns < RemainingTokenColumns), function breakProtrudingToken, file /Users/mhorn/Projekte/foreign/llvm-project/llvm/tools/clang/lib/Format/ContinuationIndenter.cpp, line 941. 0 clang-format 0x00000001092e4e4e llvm::sys::PrintStackTrace(__sFILE*) + 46 1 clang-format 0x00000001092e515b PrintStackTraceSignalHandler(void*) + 27 2 clang-format 0x00000001092e54d8 SignalHandler(int) + 408 3 libsystem_c.dylib 0x00007fff8ffab90a _sigtramp + 26 4 libsystem_c.dylib 0x00007fff56b58be8 _sigtramp + 3334132472 5 clang-format 0x00000001092e518b raise + 27 6 clang-format 0x00000001092e5242 abort + 18 7 clang-format 0x00000001092e5221 __assert_rtn + 129 8 clang-format 0x00000001090b9fb0 clang::format::ContinuationIndenter::breakProtrudingToken(clang::format::FormatToken const&, clang::format::LineState&, bool) + 4704 9 clang-format 0x00000001090b5d12 clang::format::ContinuationIndenter::moveStateToNextToken(clang::format::LineState&, bool, bool) + 7826 10 clang-format 0x00000001090b7948 clang::format::ContinuationIndenter::addTokenToState(clang::format::LineState&, bool, bool, unsigned int) + 520 11 clang-format 0x00000001090c3653 clang::format::(anonymous namespace)::UnwrappedLineFormatter::addNextStateToQueue(unsigned int, clang::format::(anonymous namespace)::UnwrappedLineFormatter::StateNode*, bool, unsigned int*, std::__1::priority_queue<std::__1::pair<std::__1::pair<unsigned int, unsigned int>, clang::format::(anonymous namespace)::UnwrappedLineFormatter::StateNode*>, std::__1::vector<std::__1::pair<std::__1::pair<unsigned int, unsigned int>, clang::format::(anonymous namespace)::UnwrappedLineFormatter::StateNode*>, std::__1::allocator<std::__1::pair<std::__1::pair<unsigned int, unsigned int>, clang::format::(anonymous namespace)::UnwrappedLineFormatter::StateNode*> > >, std::__1::greater<std::__1::pair<std::__1::pair<unsigned int, unsigned int>, clang::format::(anonymous namespace)::UnwrappedLineFormatter::StateNode*> > >*) + 435 12 clang-format 0x00000001090c3211 clang::format::(anonymous namespace)::UnwrappedLineFormatter::analyzeSolutionSpace(clang::format::LineState&, bool) + 4273 13 clang-format 0x00000001090c2135 clang::format::(anonymous namespace)::UnwrappedLineFormatter::format(clang::format::AnnotatedLine const&, unsigned int, bool) + 149 14 clang-format 0x00000001090c0e02 clang::format::(anonymous namespace)::UnwrappedLineFormatter::format(llvm::SmallVectorImpl<clang::format::AnnotatedLine*> const&, bool, int, bool) + 3138 15 clang-format 0x00000001090bf895 clang::format::(anonymous namespace)::Formatter::format(llvm::SmallVectorImpl<clang::format::AnnotatedLine*>&, bool, clang::format::(anonymous namespace)::FormatTokenLexer&) + 693 16 clang-format 0x00000001090bd981 clang::format::(anonymous namespace)::Formatter::format() + 929 17 clang-format 0x00000001090bd554 clang::format::reformat(clang::format::FormatStyle const&, clang::Lexer&, clang::SourceManager&, std::__1::vector<clang::CharSourceRange, std::__1::allocator<clang::CharSourceRange> >) + 100 18 clang-format 0x00000001090a2a07 clang::format::format(llvm::StringRef) + 1735 19 clang-format 0x00000001090a2118 main + 1192 20 libdyld.dylib 0x00007fff91ea07e1 start + 0 21 libdyld.dylib 0x0000000000000002 start + 1846933537 Illegal instruction: 4
Fixed in r206295.