[PATCH] D111273: [clang-format-diff] Fix missing formatting for zero length git diff lines

Lang Hames via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 18 18:19:50 PDT 2021


lhames added a comment.

Heads up -- I think I just hit an error due to this while formatting a local commit:

  % ./clang/tools/clang-format/git-clang-format HEAD~1                                                                                                   
  Assertion failed: (Line && Col && "Line and column should start from 1!"), function translateLineCol, file ./llvm-project/clang/lib/Basic/SourceManager.cpp, line 1699.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.            
  Stack dump:                                                                                                    
  0.      Program arguments: clang-format -lines=15:15 -lines=24:24 -lines=46:47 -lines=73:74 -lines=82:82 -lines=117:117 -lines=128:128 -lines=168:168 -lines=177:177 -lines=0:0 llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.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  clang-format             0x0000000101390dad llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 61
  1  clang-format             0x000000010139135b PrintStackTraceSignalHandler(void*) + 27
  2  clang-format             0x000000010138f00b llvm::sys::RunSignalHandlers() + 123                            
  3  clang-format             0x0000000101393fb8 SignalHandler(int) + 232                                        
  4  libsystem_platform.dylib 0x00007fff20639d7d _sigtramp + 29                                                  
  5  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603339972764320
  6  libsystem_c.dylib        0x00007fff20549411 abort + 120                                                                                                                                                                     
  7  libsystem_c.dylib        0x00007fff205487e8 err + 0
  8  clang-format             0x000000010146e898 clang::SourceManager::translateLineCol(clang::FileID, unsigned int, unsigned int) const + 136
  9  clang-format             0x00000001011eb586 clang::format::fillRanges(llvm::MemoryBuffer*, std::__1::vector<clang::tooling::Range, std::__1::allocator<clang::tooling::Range> >&) + 966                                     
  10 clang-format             0x00000001011dd718 clang::format::format(llvm::StringRef) + 1064                   
  11 clang-format             0x00000001011dcc1b main + 955                                                                                                                                                                      
  12 libdyld.dylib            0x00007fff2060ff3d start + 1                                                       
  13 libdyld.dylib            0x000000000000000c start + 18446603339972935888                                                                                                                                                    
  error: `clang-format -lines=15:15 -lines=24:24 -lines=46:47 -lines=73:74 -lines=82:82 -lines=117:117 -lines=128:128 -lines=168:168 -lines=177:177 -lines=0:0 llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp` failed

Reverting this patch fixed the error.

I am able to reliably reproduce this crash on Darwin by running:

  % git checkout fd26ca4e7515e7dd32ae02e777bd21693afc68ff
  % git am jitlink-table-manager-updates.patch
  % ./clang/tools/clang-format/git-clang-format HEAD~1

F19699034: jitlink-table-manager-updates.patch <https://reviews.llvm.org/F19699034>


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111273/new/

https://reviews.llvm.org/D111273



More information about the cfe-commits mailing list