-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Omnisharp gets stuck at 100% CPU when analyzing complex Automapper profiles #4072
Comments
I've just discovered a simple "workaround": if the source file that triggers the bug contains a syntax error (eg: mispelled field name), the error is obviously marked in red in vscode and omnisharp/intellisense works perfectly. |
Same situation for me on the exact same config except for the OS (Mac OS X 10.15.6) and VSCode (1.42.1). |
Steps to reproduce with a very simple program:
using System;
namespace omnisharp_bug
{
class TestModel
{
public string field1 { get; set; }
public string field2 { get; set; }
public string field3 { get; set; }
public string field4 { get; set; }
public string field5 { get; set; }
public string field6 { get; set; }
public string field7 { get; set; }
public string field8 { get; set; }
public string field9 { get; set; }
public string field10 { get; set; }
}
class TestDto
{
public string field1 { get; set; }
public string field2 { get; set; }
public string field3 { get; set; }
public string field4 { get; set; }
public string field5 { get; set; }
public string field6 { get; set; }
public string field7 { get; set; }
public string field8 { get; set; }
public string field9 { get; set; }
public string field10 { get; set; }
}
public class MapperProfile : AutoMapper.Profile
{
public MapperProfile()
{
}
public void MapTest()
{
CreateMap<TestModel, TestDto>()
.ForMember(dest => dest.field1, opt => opt.MapFrom(src => src.field1))
.ForMember(dest => dest.field2, opt => opt.MapFrom(src => src.field2))
.ForMember(dest => dest.field3, opt => opt.MapFrom(src => src.field3))
.ForMember(dest => dest.field4, opt => opt.MapFrom(src => src.field4))
.ForMember(dest => dest.field5, opt => opt.MapFrom(src => src.field5))
.ForMember(dest => dest.field6, opt => opt.MapFrom(src => src.field6))
.ForMember(dest => dest.field7, opt => opt.MapFrom(src => src.field7))
.ForMember(dest => dest.field8, opt => opt.MapFrom(src => src.field8))
.ForMember(dest => dest.field9, opt => opt.MapFrom(src => src.field9))
// to trigger the bug:
// 1. wait for OmniSharp to initialize
// 2. delete "field10" in src and press ctrl+space for autocompletion (in case 2/3 times if needed)
// 3. mono process goes 100% CPU, completion does not work and vscode becomes unusable
.ForMember(dest => dest.field10, opt => opt.MapFrom(src => src.field10))
;
CreateMap<TestDto, TestModel>()
.ForMember(dest => dest.field1, opt => opt.MapFrom(src => src.field1))
.ForMember(dest => dest.field2, opt => opt.MapFrom(src => src.field2))
.ForMember(dest => dest.field3, opt => opt.MapFrom(src => src.field3))
.ForMember(dest => dest.field4, opt => opt.MapFrom(src => src.field4))
.ForMember(dest => dest.field5, opt => opt.MapFrom(src => src.field5))
.ForMember(dest => dest.field6, opt => opt.MapFrom(src => src.field6))
.ForMember(dest => dest.field7, opt => opt.MapFrom(src => src.field7))
.ForMember(dest => dest.field8, opt => opt.MapFrom(src => src.field8))
.ForMember(dest => dest.field9, opt => opt.MapFrom(src => src.field9))
.ForMember(dest => dest.field10, opt => opt.MapFrom(src => src.field10))
;
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
} |
If you mark the folder that Automapper is generating as generated code into I would expect this to no longer repo.
|
AFAIK |
@JoeRobich @jmarolf at least the stack trace suggests a Roslyn bug, we should be able to isolate it into a repro without OmniSharp |
This bug gets triggered with any source file that uses non trivial lambda expressions (eg: |
Some updates regarding this issue:
|
That is an interesting bit of additional information. We only surface reference count and testing commands via the CodeLens. In this case I would suspect finding references to be the expensive operation. In the past we have excluded finding references for certain methods, such as object.ToString, since they are implemented by virtually everything and occur frequently in code. I wonder if there is another method or set of methods that we should exclude for performance. |
As mentioned above, the issue arises in source files where there is heavy use of lambda expressions. I think it would be nice to have an option to disable |
Sadly if the source file is complex, the bug arises even with |
The workaround didn't work for me. I had to avoid creating new mapping with more than 5 lines approx. Otherwise, I must restart my VSCode every 5min 😞 |
@plsgard Today I've:
thereafter the bug seems resolved (so far ...) |
Nope, the bug is still here, sometimes does not get triggered but usually is ... Sadly I'll have to switch to Visual Studio as VS Code is pratically unusable for me ... |
Still a problem with 1.37.15. It's related to complex (nested?) lambda expression, not code lens. This issue makes VSCode unusable for moderate to large projects. I've had to switch to Rider. |
Closing due to lack of activity. |
Issue Description
Omnisharp intellisense stops working and Omnisharp process CPU gets stuck at 100% idenfinitely.
Steps to Reproduce
It happens when OmniSharp analyzes complex
AutoMapper
profiles. If needed I could try to create a minimal project to reproduce it; the code I'm actually working on and that causes the bug is large and is not opensource.Expected Behavior
Omnisharp intellisense should work as usual
Actual Behavior
Intellisense freezes, CPU for OmniSharp exe process goes 100% indefinitely, vscode becomes unusable and must be restarted.
Logs
Thread dump for stuck threads is the following:
and
OmniSharp log
Environment information
VSCode version: 1.49.0
C# Extension: 1.23.2
Mono Information
OmniSharp using built-in monoDotnet Information
.NET Core SDK (reflecting any global.json): Version: 3.1.402 Commit: 9b5de826fdRuntime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /usr/share/dotnet/sdk/3.1.402/
Host (useful for support):
Version: 3.1.8
Commit: 9c1330dedd
.NET Core SDKs installed:
2.2.402 [/usr/share/dotnet/sdk]
3.1.402 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
The text was updated successfully, but these errors were encountered: