-
Notifications
You must be signed in to change notification settings - Fork 470
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
dotnet build doesn't terminate in 5.0.200, same code compiles in previous version. #4920
Comments
What version of the compiler is included with 5.0.200? I'm not able to reproduce this in the Platform Compatibility Analyzer tests with either 3.8.0 or 3.9.0. |
Here's the test I wrote: [Fact]
[WorkItem(4920, "https://github.com/dotnet/roslyn-analyzers/issues/4920")]
public async Task FailureToTerminate()
{
var source = @"
using System.Runtime.InteropServices;
using Microsoft.Win32;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Registry.GetValue("""", """", null) != null)
{
foreach (var x in new string[0])
{
if ("""".ToString() == """")
{
try
{
}
catch
{
}
}
}
}";
await new VerifyCS.Test
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50.AddPackages(
ImmutableArray.Create(new PackageIdentity("Microsoft.Win32.Registry", "5.0.0"))),
LanguageVersion = CSharpLanguageVersion.CSharp9,
TestState =
{
OutputKind = OutputKind.ConsoleApplication,
Sources = { source },
AnalyzerConfigFiles = { ("/.editorconfig", s_msBuildPlatforms) },
}
}.RunAsync();
} |
Tagging @buyaa-n as well in case she is aware of this issue or a fix that was done. |
@sharwell |
Here is the project file that I'm using + the global.json
{
"sdk": {
"version": "5.0.200"
}
} Confirmed that this does use 5.0.200 on my machine C:\Users\jaredpar\temp\console> dotnet --version
5.0.200 |
Hm, I was not aware of this issue, i can repro with a sample console app. There is something related to |
This comment has been minimized.
This comment has been minimized.
@jaredpar Can you add a copy of the .globalconfig produced during your test build above? It's generated in the obj/Debug directory. |
Oh, I was finally able to reproduce this by changing the .globalconfig. |
Thanks, @sharwell i was able to repro with a similar unit test, it is a very strange edge case, if remove the guard method it builds just fine // Builds fine
if (Registry.GetValue("", "", null) != null)
{
foreach (var x in new string[0])
{
if ("""".ToString() == """")
{
try
{
}
catch
{
}
}
}
} If remove any of the blocks inside it also builds (loop or try catch or if condition) // Builds fine
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Console.CapsLock)
{
foreach (var x in new string[0])
{
if ("""".ToString() == """")
{
}
}
} When debug the flow analysis result is not returning, seems flow analysis bug |
@buyaa-n Yeah that comment was outdated. Once I fixed the .globalconfig file I was able to reproduce this and submitted #4923 with the test. Yes, I also commented today to @mavasani that we need analyzer callbacks for AnalyzerConfig documents in the compiler. Too many cases where lines get silently ignored due problems that could be easily detected and reported by analyzers. |
The test is now merged. The issue is not fixed, but writing the test is tricky so this will hopefully same someone time when they go to investigate this. |
@sharwell got it, thanks for the tests |
Seen at least two instances of this bug pretty much immediately after release. This seems very likely to need to go through servicing. |
In A little bit more down the stack, the following call is done repeatedly: roslyn-analyzers/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowAnalysis.cs Line 323 in 3fb8781
|
And finally, here is the infinite loop: roslyn-analyzers/src/Utilities/FlowAnalysis/FlowAnalysis/Framework/DataFlow/DataFlowAnalysis.cs Line 197 in 3fb8781
|
Worth looking at duplicate dotnet/roslyn#51652 . It fails in older versions also, but with a warning instead of a lockup. In case that helps diagnosis:
|
I have a fix for this issue: #4928 @jaredpar @terrajobst @jeffhandley @vatsalyaagrawal would this be a candidate for .NET5 servicing fix? |
There were two reports within the first few days of the SDK being released which speaks a bit about impact to me. How corner case is the scenario though? It's hard to tell from the bug. If it's decently mainstream I'd vote for pushing through servicing at this point. |
Apparently my fix does not fix the second hang: dotnet/roslyn#51652. I'll continue investigating.
Both cases are when there are platform guard checks inside/outside a loop with a try/catch inside a loop. |
Latest commit 44fb5c4 for #4928 fixes dotnet/roslyn#51652. |
…e value merge Fixes dotnet#4920
This problem has reappeared in SDK 5.0.403. Problem does not exist however in SDK 6.0.100. |
There is something wrong with the latest |
Version Used: 5.0.200
Steps to Reproduce:
dotnet add package Microsoft.Win32.Registry
Expected Behavior:
dotnet build
compiles the projectActual Behavior:
dotnet build
hangs indefinitely.The text was updated successfully, but these errors were encountered: