llvm / llvm/llvm-project

Crash running clang-tidy, in "bugprone-unique-ptr-array-mismatch"

Open
#217,375 9 comments 0 reactions 0 assignees View on GitHub
clang-tidy confirmed crash-on-valid good first issue
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This issue just started for me. I recently updated VS 2026 to the latest release, but I’ve also been adding settings to my .clang-tidy file. Clang-tidy.exe is version “LLVM version 22.1.3” . I don’t know if the version got updated with the latest VS install.
The crash is related to the 'bugprone-unique-ptr-array-mismatch' check. If I disable it with “-bugprone-unique-ptr-array-mismatch” , the crash does not happen. The recent changes to my .clang-tidy file were not related to any “bugprone*” settings.

I don’t have a simple repro case at this time.

The referenced line (242 in socket.h) interestingly contains a coding error that was flagged recently, but hadn't yet been addressed. Fixing the bug in our code stops clang-tidy.exe from crashing.

```c++
const std::unique_ptr b( new char[l] );
```

should be:

```c++
const std::unique_ptr b( new char[l] );
```

Below is the stack dump from when the error existed in our code.

```
Build started at 11:22 AM...
1>------ Build started: Project: Software, Configuration: Debug x64 ------
1> CollectorClientbuf.cpp
C:\Repos\Software\Include\CriticalSection.h(32): warning C26165: Possibly failing to release lock 'this->cs' in function 'CriticalSection::Take'.
C:\Repos\Software\Include\CriticalSection.h(40): warning C26110: Caller failing to hold lock 'this->cs' before calling function 'CriticalSection::Leave'.
C:\Repos\Software\Include\CriticalSection.h(44): warning C26116: Failing to acquire or to hold lock 'this->cs' in function 'CriticalSection::TryEnter'.
C:\Repos\Software\Include\CriticalSection.h(47): warning C26165: Possibly failing to release lock 'this->cs' in function 'CriticalSection::TryTake'.
C:\Repos\Software\Include\CriticalSection.h(54): warning C26165: Possibly failing to release lock 'cs->cs' in function 'CriticalSection::sentry::sentry'.
C:\Repos\Software\Include\CriticalSection.h(74): warning C26110: Caller failing to hold lock 'this->cs->cs' before calling function 'CriticalSection::Leave'.
C:\Repos\Software\Include\CriticalSection.h(86): warning C26160: Caller possibly failing to hold lock 's->cs->cs' before calling function 'CriticalSection::Leave'.
C:\Repos\Software\Include\CriticalSection.h(89): warning C26165: Possibly failing to release lock 'this->s->cs->cs' in function 'CriticalSection::anti_sentry::~anti_sentry'.
C:\Repos\Software\Include\Mutex.h(82): warning C26110: Caller failing to hold lock 'this->m->handle' before calling function 'Mutex::Release'.
C:\Repos\Software\Include\Mutex.h(101): warning C26160: Caller possibly failing to hold lock 's->m->handle' before calling function 'Mutex::Release'.
C:\Repos\Software\Include\LockableStreambuf.h(43): warning C26110: Caller failing to hold lock '(& this->gmutex)->handle' before calling function 'Mutex::Release'.
C:\Repos\Software\Include\LockableStreambuf.h(49): warning C26110: Caller failing to hold lock '(& this->pmutex)->handle' before calling function 'Mutex::Release'.
C:\Repos\Software\Include\NTThread.h(91): warning C6258: Using TerminateThread does not allow proper thread clean up.
[1/2] Processing file C:\Repos\Software\code\DDCS\CollectorClientbuf.cpp.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: "c:\\program files\\microsoft visual studio\\18\\enterprise\\VC\\Tools\\Llvm\\x64\\bin\\clang-tidy.exe" C:\\Repos\\Software\\code\\DDCS\\CollectorClientbuf.cpp C:\\Repos\\Software\\code\\StdAfx.cpp "-p=..\\build\\Temp\\x64 Debug\\Software142.ClangTidy"
1. parser at end of file
2. ASTMatcher: Processing 'bugprone-unique-ptr-array-mismatch' against:
CXXConstructExpr : <..\Include\Socket.h:242:31, col:46>
--- Bound Nodes Begin ---
found_construct_expr - { CXXConstructExpr : <..\Include\Socket.h:242:31, col:46> }
found_constructor - { CXXConstructorDecl std::unique_ptr::unique_ptr : }
found_new_expr - { CXXNewExpr : <..\Include\Socket.h:242:34, col:44> }
pointer_type - { QualType : char }
--- Bound Nodes End ---
Exception Code: 0xC0000005
#0 0x00007ff782589392 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x1809392)
#1 0x00007ff781f306f3 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b06f3)
#2 0x00007ff7821b6624 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x1436624)
#3 0x00007ff781f2fd85 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11afd85)
#4 0x00007ff781f35d16 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b5d16)
#5 0x00007ff781f40c77 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11c0c77)
#6 0x00007ff781f33531 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b3531)
#7 0x00007ff781f31d24 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b1d24)
#8 0x00007ff781f3df56 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11bdf56)
#9 0x00007ff781f3a26a (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11ba26a)
#10 0x00007ff781f35d24 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b5d24)
#11 0x00007ff781f40b1f (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11c0b1f)
#12 0x00007ff781f33491 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b3491)
#13 0x00007ff781f31c14 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b1c14)
#14 0x00007ff781f3fe2c (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11bfe2c)
#15 0x00007ff781f341af (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b41af)
#16 0x00007ff781f31f84 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b1f84)
#17 0x00007ff781f3fe2c (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11bfe2c)
#18 0x00007ff781f32fa5 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b2fa5)
#19 0x00007ff781f31b54 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b1b54)
#20 0x00007ff781f3fe2c (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11bfe2c)
#21 0x00007ff781f32155 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b2155)
#22 0x00007ff781f31ac2 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11b1ac2)
#23 0x00007ff781f1b684 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x119b684)
#24 0x00007ff781f4a193 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x11ca193)
#25 0x00007ff781ad1270 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0xd51270)
#26 0x00007ff780d85813 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x5813)
#27 0x00007ff780d8540d (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x540d)
#28 0x00007ff7811f8165 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x478165)
#29 0x00007ff78111c008 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x39c008)
#30 0x00007ff7811f7fd5 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x477fd5)
#31 0x00007ff7811f701c (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x47701c)
#32 0x00007ff7811f9f42 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x479f42)
#33 0x00007ff781118203 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x398203)
#34 0x00007ff781e8d7f0 (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x110d7f0)
#35 0x00007ff781e2979c (c:\program files\microsoft visual studio\18\enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe+0x10a979c)
#36 0x00007fff870ae957 (C:\WINDOWS\System32\KERNEL32.DLL+0x2e957)
#37 0x00007fff8844ad6c (C:\WINDOWS\SYSTEM32\ntdll.dll+0xaad6c)
c:\program files\microsoft visual studio\18\enterprise\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.ClangTidy.targets(228,5): error MSB6006: "clang-tidy.exe" exited with code -1073741819.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 11:23 AM and took 09.720 seconds ==========
```

Contributor guide

Open the contributing guide

Research direction

Start with the AST-matcher stack dump for bugprone-unique-ptr-array-mismatch and the C++ construct in Include/Socket.h:242, using clang-tidy 22.1.3 with that check enabled. Reduce the reported unique_ptr and array-allocation case into a reproducible input if possible. Done means clang-tidy no longer crashes while processing the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.