llvm / llvm/llvm-project

clang-format crash

Open
#165,977 2 comments 0 reactions 0 assignees View on GitHub
clang-format crash
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```
clang-format --version
Debian clang-format version 16.0.6 (15~deb12u1)
```
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /usr/bin/clang-format --Wno-error=unknown third_party/freetype/src/cache/ftcbasic.c
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVM-16.so.1 0x00007ff41ffc9ce6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1 libLLVM-16.so.1 0x00007ff41ffc7f30 llvm::sys::RunSignalHandlers() + 80
2 libLLVM-16.so.1 0x00007ff41ffca4bb
3 libc.so.6 0x00007ff41ee5a050
4 libclang-cpp.so.16 0x00007ff4297448f3
5 libclang-cpp.so.16 0x00007ff4297443ae clang::format::WhitespaceManager::alignArrayInitializersLeftJustified(clang::format::WhitespaceManager::CellDescriptions&&) + 286
6 libclang-cpp.so.16 0x00007ff429742c8e clang::format::WhitespaceManager::alignArrayInitializers(unsigned int, unsigned int) + 110
7 libclang-cpp.so.16 0x00007ff42973f9a6 clang::format::WhitespaceManager::generateReplacements() + 374
8 libclang-cpp.so.16 0x00007ff4296e6578
9 libclang-cpp.so.16 0x00007ff429719355 clang::format::TokenAnalyzer::process(bool) + 1045
10 libclang-cpp.so.16 0x00007ff4296f59ad
11 libclang-cpp.so.16 0x00007ff4296dec2a clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 2234
12 libclang-cpp.so.16 0x00007ff4296dfd31 clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 81
13 clang-format 0x00005598cce822f0
14 clang-format 0x00005598cce80d74
15 libc.so.6 0x00007ff41ee4524a
16 libc.so.6 0x00007ff41ee45305 __libc_start_main + 133
17 clang-format 0x00005598cce7de71
Segmentation fault
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /usr/bin/clang-format --Wno-error=unknown third_party/freetype/src/type1/t1driver.c
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVM-16.so.1 0x00007fb9307c9ce6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1 libLLVM-16.so.1 0x00007fb9307c7f30 llvm::sys::RunSignalHandlers() + 80
2 libLLVM-16.so.1 0x00007fb9307ca4bb
3 libc.so.6 0x00007fb92f65a050
4 libclang-cpp.so.16 0x00007fb939f44960
5 libclang-cpp.so.16 0x00007fb939f443ae clang::format::WhitespaceManager::alignArrayInitializersLeftJustified(clang::format::WhitespaceManager::CellDescriptions&&) + 286
6 libclang-cpp.so.16 0x00007fb939f42c8e clang::format::WhitespaceManager::alignArrayInitializers(unsigned int, unsigned int) + 110
7 libclang-cpp.so.16 0x00007fb939f3f9a6 clang::format::WhitespaceManager::generateReplacements() + 374
8 libclang-cpp.so.16 0x00007fb939ee6578
9 libclang-cpp.so.16 0x00007fb939f19355 clang::format::TokenAnalyzer::process(bool) + 1045
10 libclang-cpp.so.16 0x00007fb939ef59ad
11 libclang-cpp.so.16 0x00007fb939edec2a clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 2234
12 libclang-cpp.so.16 0x00007fb939edfd31 clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 81
13 clang-format 0x000055b1c9ebb2f0
14 clang-format 0x000055b1c9eb9d74
15 libc.so.6 0x00007fb92f64524a
16 libc.so.6 0x00007fb92f645305 __libc_start_main + 133
17 clang-format 0x000055b1c9eb6e71
Segmentation fault
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /usr/bin/clang-format --Wno-error=unknown third_party/freetype/src/type42/t42drivr.c
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVM-16.so.1 0x00007f4a293c9ce6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1 libLLVM-16.so.1 0x00007f4a293c7f30 llvm::sys::RunSignalHandlers() + 80
2 libLLVM-16.so.1 0x00007f4a293ca4bb
3 libc.so.6 0x00007f4a2825a050
4 libclang-cpp.so.16 0x00007f4a32b4497d
5 libclang-cpp.so.16 0x00007f4a32b443ae clang::format::WhitespaceManager::alignArrayInitializersLeftJustified(clang::format::WhitespaceManager::CellDescriptions&&) + 286
6 libclang-cpp.so.16 0x00007f4a32b42c8e clang::format::WhitespaceManager::alignArrayInitializers(unsigned int, unsigned int) + 110
7 libclang-cpp.so.16 0x00007f4a32b3f9a6 clang::format::WhitespaceManager::generateReplacements() + 374
8 libclang-cpp.so.16 0x00007f4a32ae6578
9 libclang-cpp.so.16 0x00007f4a32b19355 clang::format::TokenAnalyzer::process(bool) + 1045
10 libclang-cpp.so.16 0x00007f4a32af59ad
11 libclang-cpp.so.16 0x00007f4a32adec2a clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 2234
12 libclang-cpp.so.16 0x00007f4a32adfd31 clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 81
13 clang-format 0x0000558d52ef12f0
14 clang-format 0x0000558d52eefd74
15 libc.so.6 0x00007f4a2824524a
16 libc.so.6 0x00007f4a28245305 __libc_start_main + 133
17 clang-format 0x0000558d52eece71
Segmentation fault
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /usr/bin/clang-format --Wno-error=unknown third_party/pcre2/src/pcre2_ucd.c
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVM-16.so.1 0x00007fab88dc9ce6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1 libLLVM-16.so.1 0x00007fab88dc7f30 llvm::sys::RunSignalHandlers() + 80
2 libLLVM-16.so.1 0x00007fab88dca4bb
3 libc.so.6 0x00007fab87c5a050
4 libclang-cpp.so.16 0x00007fab9254496a
5 libclang-cpp.so.16 0x00007fab925443ae clang::format::WhitespaceManager::alignArrayInitializersLeftJustified(clang::format::WhitespaceManager::CellDescriptions&&) + 286
6 libclang-cpp.so.16 0x00007fab92542c8e clang::format::WhitespaceManager::alignArrayInitializers(unsigned int, unsigned int) + 110
7 libclang-cpp.so.16 0x00007fab9253f9a6 clang::format::WhitespaceManager::generateReplacements() + 374
8 libclang-cpp.so.16 0x00007fab924e6578
9 libclang-cpp.so.16 0x00007fab92519355 clang::format::TokenAnalyzer::process(bool) + 1045
10 libclang-cpp.so.16 0x00007fab924f59ad
11 libclang-cpp.so.16 0x00007fab924dec2a clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 2234
12 libclang-cpp.so.16 0x00007fab924dfd31 clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 81
13 clang-format 0x00005644ede7e2f0
14 clang-format 0x00005644ede7cd74
15 libc.so.6 0x00007fab87c4524a
16 libc.so.6 0x00007fab87c45305 __libc_start_main + 133
17 clang-format 0x00005644ede79e71
Segmentation fault
```
.clang-format:
```
# Commented out parameters are those with the same value as base LLVM style.
# Uncomment parameters to change their value, or
# enforce the chosen value in case the base version style changes.
# Current base version: 17

# Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Left
AlignConsecutiveAssignments:
Enabled: true
# AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
# PadOperators: true
AlignConsecutiveBitFields:
Enabled: true
# AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
PadOperators: true
# AlignConsecutiveDeclarations:
# Enabled: false
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCompound: false
# PadOperators: false
AlignConsecutiveMacros:
Enabled: true
# AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
PadOperators: true
# AlignConsecutiveShortCaseStatements:
# Enabled: false
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCaseColons: false
# AlignEscapedNewlines: Right
AlignOperands: AlignAfterOperator
# AlignTrailingComments:
# Kind: Always
# OverEmptyLines: 0
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
# AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: Empty
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
# AttributeMacros:
BinPackArguments: false
BinPackParameters: false
# BitFieldColonSpacing: Both
BraceWrapping:
# AfterCaseLabel: false
# AfterClass: false
# AfterControlStatement: Never
# AfterEnum: false
# AfterExternBlock: false
# AfterFunction: false
# AfterNamespace: false
# AfterObjCDeclaration: false
# AfterStruct: false
# AfterUnion: false
# BeforeCatch: false
# BeforeElse: false
# BeforeLambdaBody: false
# BeforeWhile: false
# IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
# SplitEmptyNamespace: true
BreakAfterAttributes: Always
BreakAfterJavaFieldAnnotations: true
BreakArrays: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
# BreakBeforeConceptDeclarations: Always
# BreakBeforeInlineASMColon: OnlyMultiline
# BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
# BreakStringLiterals: true
# ColumnLimit: 80
CommentPragmas: ''
# CompactNamespaces: false
# ConstructorInitializerIndentWidth: 4
# ContinuationIndentWidth: 4
# Cpp11BracedListStyle: true
# DerivePointerAlignment: false
# DisableFormat: false
# EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
# ExperimentalAutoDetectBinPacking: false
# FixNamespaceComments: true
# ForEachMacros:
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
# IfMacros:
# - KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '".*"'
Priority: 1
# SortPriority: 0
# CaseSensitive: false
- Regex: '^<.*'
Priority: 2
# SortPriority: 0
# CaseSensitive: false
IncludeIsMainRegex: '$'
# IncludeIsMainSourceRegex: ''
# IndentAccessModifiers: false
# IndentCaseBlocks: false
IndentCaseLabels: true
# IndentExternBlock: AfterExternBlock
# IndentGotoLabels: true
# IndentPPDirectives: None
# IndentRequiresClause: true
IndentWidth: 4
# IndentWrappedFunctionNames: false
InsertBraces: true
InsertNewlineAtEOF: true
InsertTrailingCommas: Wrapped
# IntegerLiteralSeparator:
# Binary: 0
# BinaryMinDigits: 0
# Decimal: 0
# DecimalMinDigits: 0
# Hex: 0
# HexMinDigits: 0
JavaImportGroups: ['com.rebeltoolbox', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax']
JavaScriptQuotes: Single
# JavaScriptWrapImports: true
# KeepEmptyLinesAtEOF: false
KeepEmptyLinesAtTheStartOfBlocks: false
# LambdaBodyIndentation: Signature
# LineEnding: DeriveLF
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# Macros:
# MaxEmptyLinesToKeep: 1
# NamespaceIndentation: None
# NamespaceMacros:
# ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
# ObjCBreakBeforeNestedBlockParam: true
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: CurrentLine
# PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 0
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 120
# PenaltyBreakOpenParenthesis: 0
# PenaltyBreakString: 1000
# PenaltyBreakTemplateDeclaration: 10
# PenaltyExcessCharacter: 1000000
# PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
# PPIndentWidth: -1
# QualifierAlignment: Leave
# QualifierOrder:
# RawStringFormats:
# ReferenceAlignment: Pointer
# ReflowComments: true
# RemoveBracesLLVM: false
# RemoveParentheses: Leave
# RemoveSemicolon: false
# RequiresClausePosition: OwnLine
# RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 0
# SortIncludes: CaseSensitive
# SortJavaStaticImport: Before
SortUsingDeclarations: Lexicographic
# SpaceAfterCStyleCast: false
# SpaceAfterLogicalNot: false
# SpaceAfterTemplateKeyword: true
# SpaceAroundPointerQualifiers: Default
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeCaseColon: false
# SpaceBeforeCpp11BracedList: false
# SpaceBeforeCtorInitializerColon: true
# SpaceBeforeInheritanceColon: true
# SpaceBeforeJsonColon: false
# SpaceBeforeParens: ControlStatements
# SpaceBeforeParensOptions:
# AfterControlStatements: true
# AfterForeachMacros: true
# AfterFunctionDefinitionName: false
# AfterFunctionDeclarationName: false
# AfterIfMacros: true
# AfterOverloadedOperator: false
# AfterRequiresInClause: false
# AfterRequiresInExpression: false
# BeforeNonEmptyParentheses: false
# SpaceBeforeRangeBasedForLoopColon: true
# SpaceBeforeSquareBrackets: false
# SpaceInEmptyBlock: false
# SpacesBeforeTrailingComments: 1
# SpacesInAngles: Never
# SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
# Minimum: 1
Maximum: 1
# SpacesInParens: Never
# SpacesInParensOptions:
# InConditionalStatements: false
# InCStyleCasts: false
# InEmptyParentheses: false
# Other: false
# SpacesInSquareBrackets: false
Standard: c++14
# StatementAttributeLikeMacros:
# - Q_EMIT
# StatementMacros:
# - Q_UNUSED
# - QT_REQUIRE_VERSION
TabWidth: 4
# TypeNames:
# TypenameMacros:
# UseTab: Never
# VerilogBreakBetweenInstancePorts: true
# WhitespaceSensitiveMacros:
```
I don't know what else to add. I run clang-format via a pre-commit hook. Normally it works. This crash happens consistently on a branch I'm working on. The change involves renaming a directory; so it runs on every file affected, but there shouldn't be any formatting changes required.

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with clang-format 16.0.6 on the listed third_party/freetype and third_party/pcre2 C files using the supplied .clang-format configuration. Start at WhitespaceManager::alignArrayInitializersLeftJustified in the stack trace and compare the affected inputs. Done means clang-format no longer segfaults on these files and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.