roslyn: Changing constraint from "struct" to "unmanaged" causes stack overflow and VS crash.

I’m working on some code in VS 2017 (v 15.9.2) using v 7.3 of C#. This is a small console app but does some low level memory manipulation. I was refactoring the code earlier and decided that a constraint could be adjusted to unmanaged rather than struct to support some richer operations.

Before this change the code compiles and runs exactly as expected. The code here is basically a generic struct where the T is itself constrained to be struct - changing this constraint to unmanaged is what leads to the failure.

I then decided to edit Program.cs in notepad just to change the constraint and then re-opened the solution in VS. I opened the solution (but not Program.cs) and ran a build, the build soon failed with stack overflow.

I then opened Program.cs again (in VS 2017) and VS simply freezes, stops interacting and responding to mouse etc. Left for long enough it abruptly dies and restarts.

I did explore the unmanaged constraint recently but in a simple test app and probably used an earlier version of C# than 7.3 - I had no issues. So I simply opened the solution and changed each project to C# 7.2 but again as soon as I opened Program.cs VS freezes, same thing happens when I try C# 7.1 and C# 7.0 too.

NOTE: This is not a runtime issue, so don’t suspect that the logic itself is involved, this is an IDE/compiler issue.

Thoughts?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 36 (25 by maintainers)

Commits related to this issue

Most upvoted comments

@RikkiGibson I assigned the issue to you since you’re working in that area, and the issue is not caused by my change to SignatureHelp after all. Thanks

@sharwell Yes, it is a regression caused by my recent change to signature help. Gen fixed this issue in dev16 preview2 (PR https://github.com/dotnet/roslyn/pull/30997). I’ll add a test with Tanner’s repro code to confirm.