Skip to content
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

VS 2017 addin crashes when incomplete code creates a phantom infinite loop #4

Open
ItEndsWithTens opened this issue Sep 2, 2018 · 1 comment

Comments

@ItEndsWithTens
Copy link

To be honest up front, I don't know that there's anything to be done about this, it seems rather hairy, but I can't find any issues related to it, so it seems worth bringing up.

Using a project built from the Code Preview template, and working in a form's .eto.cs file with the preview pane visible, attempting to assign a control to its own Content member creates an infinite loop that locks up the IDE and eventually crashes it. This is an admittedly boneheaded thing to do on purpose, but it can happen unintentionally, when the preview attempts to compile incomplete-but-miraculously-compilable code.

Steps to Reproduce the Problem

  1. Create a new Eto.Forms project, using Code Preview (I used separate projects per platform, but I don't think that matters for this).
  2. In the class library project, open MainForm.eto.cs, and find the line where Content is assigned. Change the assignment to instead make a local variable first, and then assign that:
var someVariable = new StackLayout
{
	Items =
	{
		"Hello World!",
		// add more controls here
	}
};



int guardVar = 4; // Just a random number, the important thing is having code here.

Content = someVariable;
  1. Immediately above the 'int guardVar = 4;' line, type "someVariable" and then a period. You should see the Intellisense pop-up that offers suggestions for members, methods, events, and the like, and you should be able to browse them without issue.
  2. Delete "someVariable.", comment out the 'int guardVar' line, and save the changes, since the next step will freeze the IDE.
  3. Once again, above the now-commented-out guardVar line, type someVariable and hit period. The Intellisense pop-up appears for a moment, then everything locks up, and the IDE's devenv.exe process may need to be manually killed with Task Manager, Process Explorer, or something similar.

Expected Behavior

The Intellisense list pops up and lets me browse for the member, method, or event I need.

Actual Behavior

The Intellisense list pops up briefly, then the IDE locks up, eventually crashing with an unhandled exception.

Specifications

  • Version: 2.4.1 and 2.5.0-build1524
  • Platform(s): N/A (crashes in IDE, while looking at code preview)
  • Operating System(s): Windows 10 x64, 1803
  • IDE: Visual Studio Community 2017 v15.8.2

My intent was to define a StackLayout, change it programatically, then assign it to the Content of a form. My ultimate goal turns out not to need that, luckily, but I initially thought it did, which led to discovering this behavior.

After the IDE stops responding, it (at least on my machine) spends several minutes frozen while WerFault.exe collects crash info, and eventually gives a message about an unhandled exception. A separate instance of VS, attached to the first one before the crash, shows it's a stack overflow.

I got the addin up and running in Debug mode, and got down into CodeDomInterfaceBuilder.Compile, only to find there were no compile errors reported, which led me to realize that because StackLayouts have a Content member, just like Forms do, the moment you type the period after someVariable, and there's no actual code between that and the Content assignment (just whitespace, newlines, and comments), the C# code provider thinks it should compile someVariable.Content = someVariable, which while undesirable is technically valid C#, and will compile. This at first appeared to be a code completion issue, like picoe/Eto#471, but it's really the period creating a mirage that triggers the crash; that said period also invokes a code completion pop-up is just a coincidence.

That being said, despite my penchant for typing lots of words, I don't know what, if anything, you can or should do about this. The C# code provider is technically compiling C# just the way it's meant to, stripping out whitespace, newlines, and comments, and as I understand loops like this are difficult to detect, to say the least. Please accept my apologies if I made you read all this for nothing, but I'd feel guilty if I didn't make the issue known. Maybe it'll help somebody else understand why their preview is crashing.

@cwensley
Copy link
Member

Hey @ItEndsWithTens, thanks for the report! I'll see if I can reproduce this one.

@cwensley cwensley transferred this issue from picoe/Eto May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants