question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Potential infinite loop parsing anonymous types.

See original GitHub issue

Reported originally by @AntonGrekov in https://github.com/dotnet/roslyn/issues/24513.

Anton provided a trace (https://developercommunity.visualstudio.com/t/RoslynCodeAnalysisServiceexe-drains-UPT/10091268) that demonstrates something going very bad with parsing anonymous types (new { ... }).

Repeating the notes from that issue:

Trace shows teh entirety of the time in:

image

Interestingly the memory allocation hit is here:

image

as a massive single outlier in the total memory allocated here:

image

This indicates one of a few possibilities here:

  1. You have a truly MASSIVE anonymous-type e.g. new { ..... OMGHUEG ... }.
  2. You have a truly MASSIVE number of anonymous-types. e.g. new { ... } ... new { ... } ... ad infinitum.
  3. The compiler has a bug where it’s effectively getting into an infinite loop while parsing anonymous-types due to some construct it doesn’t understand. This infinite loop is what is causing the huge spike in CPU and the massive memory allocations as we spin forever, making no progress, constantly allocating nodes for the body of that anonymous type.

‘3’ seems very likely, but i can’t rule out ‘1’ or ‘2’. Would you be willing to zip up all your sources and send them to me? I could then do a simple parsing analysis to see what is likely causing this.

In hte meantime. @333fred @jcouv do you know of any existing issues with parsing anonymous-types, or anything we have fixed in this area that could be causing ‘3’? Looking at the code, i can see we do have a loop that does while (IsMakingProgress(ref lastTokenPosition)). However, i personally am not familiar/comfortable with the parser’s idioms for loop parsing while ensuring progress to know if this is written correctly. This will likely take further investigation from compiler team here.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
RikkiGibsoncommented, Jul 13, 2022

It looks like the user submitted a heap dump in the Developer Community. A file which reproduces the issue (probably one with very large/complex anonymous types, possibly with syntax errors) would also help.

0reactions
msftbot[bot]commented, Aug 7, 2022

Closing this issue as we’ve seen no reply to the request for more information. If you are able to get the requested information, please add it to the issue and we will retriage it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Potential Infinite Loop!
A potential infinite loop means that a loop (a for loop in this case) might run “forever” and freeze your browser. The problem...
Read more >
Using anonymous vs nested class in an infinite loop (Java)
1 Answer 1 ... Anonymous inner classes are not "redefined for each call" - they should have exactly the same overhead as an...
Read more >
MIT Open Access Articles Detecting and escaping infinite ...
Abstract. Infinite loops can make applications unresponsive. Potential problems include lost work or output, denied access to application func-.
Read more >
How to disable live code compilation/analysis in Visual ...
The compiler has a bug where it's effectively getting into an infinite loop while parsing anonymous-types due to some construct it doesn't ...
Read more >
Potential infinite loop: exceeded 1500 iterations. at < ...
This means that a and b will never change and the for loops will continue indefinitely, causing an infinite loop. Upvote 1
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found