Skip to content

clang-format segfaults with a stack dump #157405

@TracerDS

Description

@TracerDS

I have a script that automates clang-format. For one file it crashes with this stack dump:

Stack dump:
0.      Program arguments: clang-format -i Source/panel.cpp
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.so.22.0      0x00007f98297cee56 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1  libLLVM.so.22.0      0x00007f98297cc6b3 llvm::sys::RunSignalHandlers() + 131
2  libLLVM.so.22.0      0x00007f98297cfbb4
3  libc.so.6            0x00007f98286d0d20
4  libclang-cpp.so.22.0 0x00007f9833fc9170
5  libclang-cpp.so.22.0 0x00007f9833fc8c23 clang::format::WhitespaceManager::alignArrayInitializersLeftJustified(clang::format::WhitespaceManager::CellDescriptions&&) + 387
6  libclang-cpp.so.22.0 0x00007f9833fc7502 clang::format::WhitespaceManager::alignArrayInitializers(unsigned int, unsigned int) + 110
7  libclang-cpp.so.22.0 0x00007f9833fc3dc6 clang::format::WhitespaceManager::generateReplacements() + 486
8  libclang-cpp.so.22.0 0x00007f9833f62448
9  libclang-cpp.so.22.0 0x00007f9833f94c89 clang::format::TokenAnalyzer::process(bool) + 1209
10 libclang-cpp.so.22.0 0x00007f9833f74780
11 libclang-cpp.so.22.0 0x00007f9833f5b687 clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 4231
12 libclang-cpp.so.22.0 0x00007f9833f5c501 clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 81
13 clang-format         0x0000558673a1fbf9
14 clang-format         0x0000558673a1d52f
15 libc.so.6            0x00007f98286bad68
16 libc.so.6            0x00007f98286bae25 __libc_start_main + 133
17 clang-format         0x0000558673a1a361
Segmentation fault

The file is huge (6k+ lines).
Im using clang-format in a WSL shell.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions