Details
-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
Qt Creator 9.0.1, Qt Creator 10.0.0-beta1
-
Windows 10 20H2 x64
Description
clang-tidy crashes while analyzing source files that include <comip.h> or <atlcom.h>, seemingly due to the presence of templates which use Foo<&__uuidof(T)>.
A minimized example, clang-tidy-ice.cpp
// normally from <guiddef.h> via <windows.h> typedef struct _GUID { unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[ 8 ]; } GUID; struct __declspec(uuid("00000000-0000-0000-c000-000000000046")) IUnknown; const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; using REFGUID =const GUID &; bool IsEqualGUID(REFGUID rguid1, REFGUID rguid2); template<const GUID * _IID> void template_uuid() { #if 0 //ATL/comsuppp tend to be either comparing the GUID if(IsEqualGUID(*_IID,IID_IUnknown)) { } #elif 0 // or copying it for runtime use after type-erasure GUID iid = *_IID; #else // but neither seems to be necessary. While this produces "warning: expression result unused" (as expected) // for IID_IUnknown, mentioning the parameter in any way even unused and not dereferenced, // seems to be enough to provoke the crash when using __uuidof _IID; #endif } void foo() { #if 1 template_uuid<&_uuidof(IUnknown)>(); #else template_uuid<&IID_IUnknown>(); #endif }
C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe" clang-tidy-ice.cpp – -fms-extensions crashes with
PLEASE submit a bug report to [https://github.com/llvm/llvm-project/issues/] and include the crash backtrace. Stack dump: 0. Program arguments: "C:\\qt Tools Qt Creator 10.0.0-beta1\\bin\\clang bin clang-tidy.exe" clang-tidy-ice.cpp – -fms-extensions 1. <eof> parser at end of file 2. While analyzing stack: #0 Calling template_uuid() at line 37 #1 Calling foo() 3. C:/Desktop/clang-tidy-ice.cpp:30:2: Error evaluating statement 4. C:/Desktop/clang-tidy-ice.cpp:30:2: Error evaluating statement Exception Code: 0xC0000005 #0 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xbbbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xb8a42b #1 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xb6ad22 C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xb77fe6 #2 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xb4f626 C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xb617da #3 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xb4d731 C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xb4d5ce #4 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xb4c0b9 C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xddb06 #5 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xdf011 C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xe0b5b #6 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x17ebd77 C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x112b167 #7 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x548a2f C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x5af434 #8 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x1749ffb C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x16a2a03 #9 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x174764d C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x1748560 #10 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x1749750 C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xd93154 #11 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0xd9464d C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x1395 #12 0x00007ff6198dbbca C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe 0x14e6 (C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe+0xbbbbca) #13 0x00007ff6198dbbca #14 0x00007ff6198dbbca (C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe+0xbbbbca)
This crash of course prevents Analyze : clang-tidy from working on translation units which contain <comip.h> or <atlcom.h> (and probably more, but those were the two my application). I'm reporting it here rather than to LLVM because no such crash occurs with the upstream win64 releases of clang-tidy: C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe" --version claims to be version 15.0.0
C:\qt\Tools\Qt Creator 10.0.0-beta1\bin\clang\bin\clang-tidy.exe" --version
LLVM ([http://llvm.org/):] LLVM version 15.0.0 Optimized build. Default target: x86_64-w64-windows-gnu Host CPU: skylake
"C:\Program Files\llvm\bin\clang-tidy.exe" clang-tidy-ice.cpp – -fms-extensions
works, and produces the expected warning (or, in my real case, all of the expected clang-tidy modernize-use-* fixit hints I was looking for)
C:\Desktop\clang-tidy-ice.cpp:30:2: warning: expression result unused [clang-diagnostic-unused-value] _IID; ^~~~
Rather than the crash seen with Qt's build. This works in both https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/LLVM-15.0.0-win64.exe and also in the latest https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/LLVM-15.0.7-win64.exe. So the failure seems to be somehow specific to either QtCreator's configuration ,or perhaps some patches being done to your your bundled version of clang-tidy/clangd. Telling Qt Creator to use C:\Program Files\LLVM\bin\clang-tidy.exe rather than its bundled version also works.
Nothing in the 3 commits I see between llvmorg-15.0.0 and https://code.qt.io/cgit/clang/llvm-project.git/log/?h=release_15.0.0-based seems relevant, but there definitely seems to something wrong with the bundled version... I'm not sure where else to look for what Qt Creator is customizing about its bundled executables.