[llvm-bugs] [Bug 46961] New: clangd + clang-tidy + modernize-loop-convert = crash

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 2 05:50:31 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46961

            Bug ID: 46961
           Summary: clangd + clang-tidy + modernize-loop-convert = crash
           Product: clang-tools-extra
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: clangd
          Assignee: unassignedclangbugs at nondot.org
          Reporter: marzojr at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 23808
  --> https://bugs.llvm.org/attachment.cgi?id=23808&action=edit
game.cc and game.hh, the minimal testcase

This was tested on latest version available for Windows 10 x64. For some
reason, the version field only allowed me to select "unspecified".

The attached files (game.cc and game.hh), along with the following .clang-tidy,
form a minimal case that reproduces the crash:

    Checks: "-*,modernize-loop-convert"

A compilation database makes no difference; the crash happens with or without
it. clangd is started, in my case, by VSCode using the official llvm clangd
extension with the following option active:

    --clang-tidy

Other options can be added at will, but they make no difference. Options I have
tried:

    --background-index
    --header-insertion=iwyu
    --header-insertion-decorators
    --suggest-missing-includes
    -j=1
    --log=verbose

When checking the file with these (rather broad) settings, the attached code
causes a crash in clangd with the following stack trace:

 #0 0x000000000076f51c (C:\msys64\mingw64\bin\clangd.exe+0x36f51c)
     #1 0x000000000076f59c (C:\msys64\mingw64\bin\clangd.exe+0x36f59c)
     #2 0x000000000076a39b (C:\msys64\mingw64\bin\clangd.exe+0x36a39b)
     #3 0x0000000000c8fd10 (C:\msys64\mingw64\bin\clangd.exe+0x88fd10)
     #4 0x0000000000c91c03 (C:\msys64\mingw64\bin\clangd.exe+0x891c03)
     #5 0x0000000001bd4c1d (C:\msys64\mingw64\bin\clangd.exe+0x17d4c1d)
     #6 0x0000000001bfd5df (C:\msys64\mingw64\bin\clangd.exe+0x17fd5df)
     #7 0x0000000001bd618f (C:\msys64\mingw64\bin\clangd.exe+0x17d618f)
     #8 0x0000000001bf4f74 (C:\msys64\mingw64\bin\clangd.exe+0x17f4f74)
     #9 0x0000000001bf5b70 (C:\msys64\mingw64\bin\clangd.exe+0x17f5b70)
    #10 0x0000000001bf5017 (C:\msys64\mingw64\bin\clangd.exe+0x17f5017)
    #11 0x0000000001beca28 (C:\msys64\mingw64\bin\clangd.exe+0x17eca28)
    #12 0x0000000001bed50d (C:\msys64\mingw64\bin\clangd.exe+0x17ed50d)
    #13 0x0000000000956418 (C:\msys64\mingw64\bin\clangd.exe+0x556418)
    #14 0x0000000000957f78 (C:\msys64\mingw64\bin\clangd.exe+0x557f78)
    #15 0x000000000099a7e4 (C:\msys64\mingw64\bin\clangd.exe+0x59a7e4)
    #16 0x000000000099777f (C:\msys64\mingw64\bin\clangd.exe+0x59777f)
    #17 0x000000000098a49c (C:\msys64\mingw64\bin\clangd.exe+0x58a49c)
    #18 0x000000006fd40541 atomic_flag_test_and_set_explicit
(C:\msys64\mingw64\bin\libstdc++-6.dll+0x100541)
    #19 0x0000000064944f2e pthread_create_wrapper
(C:\msys64\mingw64\bin\libwinpthread-1.dll+0x4f2e)
    #20 0x00007fff0230b04a (C:\WINDOWS\System32\msvcrt.dll+0x3b04a)
    #21 0x00007fff0230b11c (C:\WINDOWS\System32\msvcrt.dll+

I tried to compile a debug version to get a more usable stack trace, but I gave
up after two days of linking. This stack trace was obtained with the "official"
msys2 package, but the crash also happens with the official LLVM version.

Running clang-tidy on its own does not reproduce the crash. If the checks are
inverted (Checks: "*,-modernize-loop-convert"), there is no crash in clangd.
Any of the following changes to the test case make the crash go away:

    - putting everything in only one file;
    - changing the map's key type to std::string;
    - manually converting the loop to a range-based for;
    - using a set instead of a map.

Other changes proved to be more irrelevant, and still led to the crash.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200802/dcdacb99/attachment.html>


More information about the llvm-bugs mailing list