Repository navigation
Language service hangs after custom provider times out #13862
Copy link
Copy link
Labels
Feature: Configuration ProviderRelated to the configurationProvider property, e.g. ms-vscode.cmake-tools, ms-vscode.makefile-tools.Related to the configurationProvider property, e.g. ms-vscode.cmake-tools, ms-vscode.makefile-tools.Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.Check the Milestone for the release in which the fix is or will be available.
Milestone
Description
Environment
- OS and Version: Windows 11 version 10.0.22631
- VS Code Version: 1.103.1
- C/C++ Extension Version: 1.26.3
Bug Summary and Steps to Reproduce
Bug Summary: When using a custom configuration provider for intellisense and the provider hits the two second timeout for providing a configuration for a file, the C/C++ language service sometimes hangs. In this state, it doesn't respond to LSP requests (e.g. hovering a symbol shows "Loading..." forever), running C/C++: Log Diagnostics does nothing and the Language Status popup shows as parsing indefinitely:
Steps to reproduce:
I can reproduce the issue with this sample configuration provider:
import { dirname } from 'path';
import * as vscode from 'vscode';
import { CppToolsApi, Version, CustomConfigurationProvider, getCppToolsApi, SourceFileConfigurationItem, WorkspaceBrowseConfiguration } from 'vscode-cpptools';
let api: CppToolsApi | undefined = undefined;
export async function activate(context: vscode.ExtensionContext) {
api = await getCppToolsApi(Version.v2);
const provider = new Provider();
if (api) {
if (api.notifyReady) {
api.registerCustomConfigurationProvider(provider);
api.notifyReady(provider);
}
}
}
export function deactivate() {
api?.dispose();
}
class Provider implements CustomConfigurationProvider {
name: string = "cpptools-provider";
extensionId: string = "cpptools-provider";
canProvideConfiguration(uri: vscode.Uri, token?: vscode.CancellationToken): Thenable<boolean> {
return Promise.resolve(true);
}
async provideConfigurations(uris: vscode.Uri[], token?: vscode.CancellationToken): Promise<SourceFileConfigurationItem[]> {
console.log(`cpptools-provider: provideConfigurations called for ${uris.length} URIs.`);
await new Promise(resolve => setTimeout(resolve, 5000)); // Simulate async work
return uris.map(uri => {
return {
uri,
configuration: {
defines: [],
includePath: [dirname(uri.fsPath)],
compilerPath: "",
standard: "c17",
compilerArgs: [],
intelliSenseMode: "windows-clang-arm",
}
};
});
}
canProvideBrowseConfiguration(token?: vscode.CancellationToken): Thenable<boolean> {
return Promise.resolve(true);
}
provideBrowseConfiguration(token?: vscode.CancellationToken): Thenable<WorkspaceBrowseConfiguration | null> {
return Promise.resolve(null);
}
canProvideBrowseConfigurationsPerFolder(token?: vscode.CancellationToken): Thenable<boolean> {
return Promise.resolve(false);
}
provideFolderBrowseConfiguration(uri: vscode.Uri, token?: vscode.CancellationToken): Thenable<WorkspaceBrowseConfiguration | null> {
throw new Error('Method not implemented.');
}
dispose() {
}
}Steps:
- Run the code above as an extension (with "*" as the activation event)
- Open a folder with a C/C++ codebase that is large enough that it takes more than ~6 seconds to index
- Open a C/C++ file to trigger the configuration provider
- Wait until the indexing would normally be finished. As far as I can tell, if running
C/C++: Log Diagnosticsproduces any output, the language service is still indexing; if it does not, the language service has hanged.
For me, this takes a few tries to hit. It only hangs about once every four tries.
Configuration and Logs
loggingLevel: 6
Custom configuration provider 'cpptools-provider' registered
LSP: (received - deferred) textDocument/didOpen: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c
LSP: (received) cpptools/initialize (id: 1)
LSP: (invoked) cpptools/initialize (id: 1)
cpptools version (TypeScript): 1.26.3
cpptools version (native): 1.26.3.0
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
LSP: Sending response (id: 1)
LSP: (received) cpptools/queryCompilerDefaults (id: 2)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 2)
Compiler info database not connected - skipping load.
Compiler info database not connected - skipping load.
LSP: Sending response (id: 2)
LSP: (received) cpptools/queryCompilerDefaults (id: 3)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 3)
Compiler info database not connected - skipping load.
Compiler info database not connected - skipping load.
LSP: Sending response (id: 3)
LSP: (received) cpptools/didChangeCppProperties (id: 4)
LSP: (invoked) cpptools/didChangeCppProperties (id: 4)
Code browsing service initialized
LSP: (received - deferred) cpptools/didChangeVisibleTextEditors
Populating file name cache...
LSP: (received) cpptools/didChangeSettings
Attempting to get defaults from C compiler in "compilerPath" property: 'cl.exe'
Attempting to get defaults from C++ compiler in "compilerPath" property: 'cl.exe'
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\CPPWINRT will be indexed
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\SHARED will be indexed
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UCRT will be indexed
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UM will be indexed
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\WINRT will be indexed
Folder: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.40.33807\ATLMFC\INCLUDE will be indexed
Folder: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.40.33807\INCLUDE will be indexed
Folder: D:\EW PROJECTS\ARM\9.50.1\ST\STM32F0XX\IAR-STM32F051R8-SK\UART-LCD will be indexed
LSP: (queued) textDocument/didOpen: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c
LSP: (queued) cpptools/didChangeVisibleTextEditors
LSP: Sending response (id: 4)
LSP: (invoked) cpptools/didChangeSettings
Discovering files...
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: (invoked) textDocument/didOpen: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Intellisense update pending for: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c
Requesting a custom configuration for: D:\EW PROJECTS\ARM\9.50.1\ST\STM32F0XX\IAR-STM32F051R8-SK\UART-LCD\MAIN.C
Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UCRT
Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\CPPWINRT
Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\SHARED
Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UM
LSP: (received) cpptools/didChangeCppProperties (id: 5)
LSP: (invoked) cpptools/didChangeCppProperties (id: 5)
Attempting to get defaults from C compiler in "compilerPath" property: 'cl.exe'
LSP: (received) cpptools/didChangeVisibleTextEditors
Attempting to get defaults from C++ compiler in "compilerPath" property: 'cl.exe'
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\CPPWINRT will be indexed
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\SHARED will be indexed
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UCRT will be indexed
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UM will be indexed
Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\WINRT will be indexed
Folder: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.40.33807\ATLMFC\INCLUDE will be indexed
Folder: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.40.33807\INCLUDE will be indexed
Folder: D:\EW PROJECTS\ARM\9.50.1\ST\STM32F0XX\IAR-STM32F051R8-SK\UART-LCD will be indexed
LSP: Sending response (id: 5)
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\WINRT
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/getDocumentSymbols: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 6)
LSP: (invoked) cpptools/getDocumentSymbols: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 6)
LSP: Sending response (id: 6)
Processing folder (non-recursive): C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.40.33807\ATLMFC\INCLUDE
LSP: (received) cpptools/getCodeActions: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 7)
LSP: (invoked) cpptools/getCodeActions: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 7)
LSP: Sending response (id: 7)
LSP: (received) cpptools/getFoldingRanges: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 8)
LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 8)
LSP: Sending response (id: 8)
LSP: (received) cpptools/pauseParsing
LSP: (invoked) cpptools/pauseParsing
LSP: (received) cpptools/clearCustomConfigurations
LSP: (invoked) cpptools/clearCustomConfigurations
LSP: (received) cpptools/getCodeActions: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 9)
LSP: (invoked) cpptools/getCodeActions: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 9)
LSP: Sending response (id: 9)
LSP: $/cancelRequest (<unknown/completed>, id: 7)
LSP: (received) cpptools/clearCustomConfigurations
LSP: (invoked) cpptools/clearCustomConfigurations
Processing folder (non-recursive): C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.40.33807\INCLUDE
Processing folder (recursive): D:\EW PROJECTS\ARM\9.50.1\ST\STM32F0XX\IAR-STM32F051R8-SK\UART-LCD
Done populating filename cache. Elapsed time: 159 ms
Discovering files: 5926 file(s) processed
0 file(s) removed from database
Done discovering files.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
IntelliSense update scheduled and TU acquisition started for: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c
Requesting a custom configuration for: D:\EW PROJECTS\ARM\9.50.1\ST\STM32F0XX\IAR-STM32F051R8-SK\UART-LCD\MAIN.C
LSP: (received) cpptools/getCodeActions: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 10)
LSP: $/cancelRequest (cpptools/getCodeActions, id: 10)
LSP: (received) cpptools/getCodeActions: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 11)
LSP: $/cancelRequest (cpptools/getCodeActions, id: 11)
LSP: (received) cpptools/getCodeActions: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 12)
LSP: (received) cpptools/resumeParsing
LSP: (received) cpptools/finishedRequestCustomConfig: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c
LSP: (invoked) cpptools/finishedRequestCustomConfig: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: $/cancelRequest (cpptools/getCodeActions, id: 12)
LSP: (received) cpptools/hover: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 13)
LSP: $/cancelRequest (cpptools/hover, id: 13)
LSP: (received) cpptools/hover: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 14)
LSP: $/cancelRequest (cpptools/hover, id: 14)
LSP: (received) cpptools/hover: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 15)
LSP: $/cancelRequest (cpptools/hover, id: 15)
LSP: (received) cpptools/hover: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 16)
LSP: $/cancelRequest (cpptools/hover, id: 16)
LSP: (received) cpptools/hover: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 17)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/getCodeActions: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 18)
LSP: $/cancelRequest (cpptools/hover, id: 17)
LSP: (received) cpptools/hover: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 19)
LSP: $/cancelRequest (cpptools/hover, id: 19)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/getCodeActions: file:///d%3A/EW%20Projects/arm/9.50.1/ST/STM32F0xx/IAR-STM32F051R8-SK/UART-LCD/main.c (id: 20)
LSP: $/cancelRequest (cpptools/getCodeActions, id: 18)Other Extensions
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Feature: Configuration ProviderRelated to the configurationProvider property, e.g. ms-vscode.cmake-tools, ms-vscode.makefile-tools.Related to the configurationProvider property, e.g. ms-vscode.cmake-tools, ms-vscode.makefile-tools.Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.Check the Milestone for the release in which the fix is or will be available.
Type
Projects
- StatusShow more project fieldsDone
Activity
sean-mcmanus commentedon Aug 20, 2025
Hampus Adolfsson (@HampusAdolfsson) I'm not able to repro the issue. If there's a timeout, it falls back to configuration using the base configuration -- do you repro the same issue if you remove the configurationProvider so that it always uses them base c_cpp_properties.json configuration? Otherwise, can you attach a debugger to the cpptools.exe process (https://github.com/microsoft/vscode-cpptools/wiki/Attaching-debugger-to-cpptools-or-cpptools%E2%80%90srv ) and look for call stacks that appear to be doing work and or doing work but our stuck (i.e. ignoring the small threads that are just idle). Also, if you set the C_Cpp.loggingLevel to the hidden value of "8" temporarily it might show more logging.
HampusAdolfsson commentedon Aug 22, 2025
Sean McManus (@sean-mcmanus) I see, it's unfortunate that it doesn't work on your end. The repro seems very timing-sensitive, but I've successfully run it on two machines so I don't think it's some machine-specific thing.
No, the base configuration works as expected.
Here are the threads doing work:
The first three threads are all waiting for the same lock, which is being held by the worker thread. The worker thread seems to be waiting indefinitely for a custom configuration even though the provider has timed out.
I also noticed that cpptools requests a custom configuration for the same file several times before it hangs, and I see multiple timeout popups in quick succession (with less than two seconds in-between):
20250822-0729-53.5764618.mp4
Here are the logs with logging level 8:
https://gist.github.com/HampusAdolfsson/d0456f1698277b7d33b2c3b498ed20b2
Colengms commentedon Aug 22, 2025
Hi Hampus Adolfsson (@HampusAdolfsson) .
Those stacks look to be expected. They don't appear to show a deadlock. They show that the native component is still waiting to receive a
FinishedRequestCustomConfigmessage from the TypeScript side, which is expected even on failure. That message is sent by a 'finally', and at a higher priority than other messages, so is always expected. Can you provide all other threads, in case there might be something else blocking our message queue? Otherwise, it seems like we should be looking at the TypeScript side to figure out why that 'finished' message is not being sent.The log you provided consists mostly of database population. Would it be possible to regenerate one, after database population is complete? Also, could you check the
Consoleoutput (under Help -> Toggle Developer Tools), as that might show evidence of an exception being thrown in the TypeScript component.HampusAdolfsson commentedon Aug 25, 2025
Colen Garoutte-Carson (@Colengms)
Here are the other stacks:
Let me know if I misunderstood you, but I've generated new logs where I:
Here's a run where I observed the deadlock:
https://gist.github.com/HampusAdolfsson/082a724e27e2f2006bab666626b78261
For reference, here's a run where I did not observe it, i.e., intellisense finished configuring correctly:
https://gist.github.com/HampusAdolfsson/8945d13d9079ae2c8e0a764468ef7b48
They look very similar to me. However, you can see that cpptools requests a custom configuration twice and in the failed run it only receives one
cpptools/finishedRequestCustomConfig.Nothing out of the ordinary here as far as I can tell:
sean-mcmanus commentedon Sep 8, 2025
Hampus Adolfsson (@HampusAdolfsson) Can you confirm that there is an info notification popup in the bottom right notification section? Does bypassing the notification fix the issue for you?
HampusAdolfsson commentedon Sep 9, 2025
Sean McManus (@sean-mcmanus) Yes, pressing 'Dismiss' on the notification fixes the issue.
Thanks for the fix Colen Garoutte-Carson (@Colengms) and Sean McManus (@sean-mcmanus)!