Version Used: vs2017 version 15.1(26403.7)
Steps to Reproduce:
Expected Behavior:
Actual Behavior:
Code: MSB6006
Descrition: "csc.exe" exited with code -2146232797
File: Microsoft.CSharp.Core.targets
Line: 71
@QJesus If I (or someone else diagnosing this) wanted to build an example to replicate your problem, they wouldn't be able to do it with the code you provided. Can you create a minimally complete example that produces this problem?
@benknoble Thank you. Here is the example. I use NETCOREAPP1_1.
When I Build Solution, I got an error as below:
Severity Code Description Project File Line Suppression State
Error MSB6006 "csc.exe" exited with code -2146232797. ConsoleApp3 C:\Program Files (x86)\Microsoft Visual Studio2017\Enterprise\MSBuild15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets 71
``` c#
using System;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
private void ResolvingPackages()
{
string Cvt2DrawerNo(int cabinetIdx, int drawerIdx) => $"{cabinetIdx:00}-01{drawerIdx:00}";
void C1(int cabinetIdx, int drawerIdx, int flag, params byte[] datas)
{
var columns = 0;
var rows = 0;
void modifyState(string binary, Func<int, int, bool> skipFunc = null)
{
var idx = 0;
for (int x = 0; x < columns; x++)
{
for (int y = 0; y < rows; y++, idx++)
{
if (skipFunc != null && skipFunc(x, y))
{
continue;
}
var no = $"{Cvt2DrawerNo(cabinetIdx, drawerIdx)}-{x + 1:X2}{y + 1:X2}";
Console.Write(no);
}
}
}
switch (rows)
{
case 3 when columns == 4 && flag == 0x21:
modifyState("");
break;
case 3 when columns == 8 && flag == 0x21:
modifyState("");
break;
case 6 when columns == 5 && flag == 0x22:
modifyState("");
break;
case 6 when columns == 7:
if (flag == 0x21)
{
modifyState("");
}
else if (flag == 0x22)
{
modifyState("");
}
break;
}
}
}
}
}
```
@agocke This looks like it may be a crash involving local functions. Can you please diagnose for triage purposes?
@gafter This looks to be a new bug -- it repros in master, as far as I can tell.
I can reduce the repro to
class Program
{
private void ResolvingPackages()
{
string outerScope(int a) => "";
void C1(int cabinetIdx)
{
void modifyState()
{
var no = outerScope(cabinetIdx);
}
modifyState();
}
}
}
and it looks a lot like #19182 .
Is this fix shipped yet? VS 15.3.5 just thrown "csc.exe" exited with code -2146232797, involving local function complex changes.
@Logerfo I cannot repro this bug right now with VS-15.3.5. Are you able to reproduce the bug from the code pasted by me or the OP?
If you are able to reproduce the code pasted in this issue, then are you sure that you’re using the roslyn shipped with VS? If I understand correctly, it is possible to use a different version of Roslyn by installing a nuget package. If you have done so, you need to either remove the nuget package to use the version provided by VS or update your nuget package to the fixed version of roslyn.
If you get a crash like this but cannot reproduce it using the code pasted in this issue, it is likely a different roslyn bug than this one. The compiler exiting with a fatal error will look like this “"csc.exe" exited with code -2146232797” regardless of the underlying cause. If you can get the compiler to crash with different code, please try reducing your code to a minimal repro and file a new issue.
@Logerfo It's possible you're hitting a slightly different instance of this bug. Could you check if your problem repros with VS 2017 15.5 Preview 1? It should be publicly available in the preview channel right now and contains fixes for all known local function lowering bugs.
@binki
Are you able to reproduce the bug from the code pasted by me or the OP?
No.
are you sure that you’re using the roslyn shipped with VS?
Yes.
is possible to use a different version of Roslyn by installing a nuget package. If you have done so...
I did not.
If you can get the compiler to crash with different code, please try reducing your code to a minimal repro
Done.
@agocke
Could you check if your problem repros with VS 2017 15.5 Preview 1?
I'm afraid I will not be able to try that until Monday. Sharplab does not crash with the above code using the master branch. Should I assume it's fixed, then?
@Logerfo
Sharplab does not crash with the above code using the master branch. Should I assume it's fixed, then?
Yup. 😄