Repository navigation
Avoid stack overflow due to deep recursion on long chain of calls. - #67913
Conversation
|
@dotnet/roslyn-compiler Please review |
|
@dotnet/roslyn-compiler Please review |
2 similar comments
|
@dotnet/roslyn-compiler Please review |
|
@dotnet/roslyn-compiler Please review |
There was a problem hiding this comment.
nit: consider moving this snapshot just before first push (calls.Push(node); on line 5719), so that for each receiver we do snapshot&push together.
nit: then the logic on expressionIsRead could be moved here (just before visitAndCheckReceiver) since the snapshot&push doesn't care about that.
(I understand that you maintained exactly the original ordering, so those are just nits to consider)
There was a problem hiding this comment.
Why don't we need to update/track the expressionIsRead value when dealing with a single invocation? #Resolved
There was a problem hiding this comment.
Why don't we need to update/track the expressionIsRead value when dealing with a single invocation?
Because the calling Visit does that. Above we are setting it for nested calls.
There was a problem hiding this comment.
The ordering for these two calls (CheckReceiverIfField(node.ReceiverOpt) and this.Visit(node.ReceiverOpt)) seems a bit different than in the original code. I'm not sure if it matters...
Is that intentional?
In comparison, the order for single invocation case below matches the previous order:
- VisitCall
- CheckReceiverIfField
- CheckReferenceToMethodIfLocalFunction
- Visit receiver
- Visit arguments #Resolved
There was a problem hiding this comment.
As far as I understand there is no order dependency between Visit and Check methods.
There was a problem hiding this comment.
It looks like we'll push at most two nodes into the invocations queue. Should this be a while loop instead? #Closed
There was a problem hiding this comment.
Should this be a while loop instead?
Yes, this is a typo.
There was a problem hiding this comment.
I have a general concern about the repetition that occurs in this PR: If we make a change to a method that is referenced by a "// Method does this before visiting each node", I'm concerned that we will not catch all these other places that should also be updated.
I don't have a great solution for this, but maybe it would be useful to add cref comments from those methods back to all the places that duplicate some of the logic.
There was a problem hiding this comment.
I guess there's also the broader question of whether the gain is worth all this additional complexity in the codebase. I'm curious what the team thinks (@dotnet/roslyn-compiler for thoughts).
There was a problem hiding this comment.
I have a general concern about the repetition that occurs in this PR: If we make a change to a method that is referenced by a "// Method does this before visiting each node", I'm concerned that we will not catch all these other places that should also be updated.
We already have to face the same for visiting binary expressions
There was a problem hiding this comment.
I didn't follow where this came from. May be worth a comment #Resolved
There was a problem hiding this comment.
I didn't follow where this came from. May be worth a comment
Added a comment
jcouv
left a comment
There was a problem hiding this comment.
LGTM Thanks (iteration 4) but would like to get team's opinion
|
@dotnet/roslyn-compiler For the second review |
|
@dotnet/roslyn-compiler For the second review |
1 similar comment
|
@dotnet/roslyn-compiler For the second review |
There was a problem hiding this comment.
Shouldn't this be while not if? #Resolved
There was a problem hiding this comment.
Shouldn't this be while not if?
Yes, the typo has been fixed already
There was a problem hiding this comment.
Seems like this is roughly the same code on several derivations of CSharpSyntaxWalker? Did you consider putting a helper directly there that we could access? Probably cost us a Delegate allocation but maybe that's not too much. #Resolved
There was a problem hiding this comment.
? Did you consider putting a helper directly there that we could access?
There are only two of them and they are slightly different. I do not think it is worth adding an abstraction across them
There was a problem hiding this comment.
Why isn't this inside the do loop below? Seems like we miss intermediate receiver calls as written. #Resolved
There was a problem hiding this comment.
Why isn't this inside the
doloop below? Seems like we miss intermediatereceivercalls as written.
The intermediate receiver is the previous call and we already visited all interesting parts of it. It is our intention to not call VisitReceiver for them. I'll add a comment.
* upstream/main: (2060 commits) implement code folding for anonymous objects Cleanup/perf in creating member maps. (dotnet#67997) Address feedback, clean the use of ILegacyGlobalOptionsWorkspaceService Update Publish.json Semantic snippets: Add inline statement snippets (dotnet#67819) Update VSSDK Build tools version Update doc comment Address feedback Move declaration near reference Address feedback Avoid stack overflow due to deep recursion on long chain of calls. (dotnet#67913) Check ILegacyGlobalOptionsWorkspaceService is null test scout queue add test update editor "Where" clause typo fix (dotnet#68002) Use `Keyword` helper method instead of hardcoding keyword help terms Move the SyntaxTree and SemanticModel action based analyzers to respect context.FilterSpan EnC refactoring: Align wrappers with contracts better (dotnet#67967) Include EA.RazorCompiler in source build (dotnet#67996) ...
The EndToEnd OverflowOnFluentCall test is fixed in #67913, but would be a significant change to backport.
…86100) Fixes #86099 Since #67913, `AbstractFlowPass.VisitCall` walks a chain of receiver calls with an explicit stack, so the receiver calls never go through `VisitAlways`. When the region passed to `AnalyzeDataFlow` is one of those receivers, the region is never entered and the analysis returns `Succeeded == false` with empty results. This calls `EnterRegionIfNeeded` for each receiver call on the way down the chain and `LeaveRegionIfNeeded` after each one is visited, like #76412 did for binary operators. The outermost call still goes through `VisitAlways`, so its region is left only after the state is restored for omitted calls. Added `Repro_86099`, `CallChainReceivers` and `CallChainReceiverWithOutArgument` to `RegionAnalysisTests`. All three fail without the change and pass with it. The rest of the Emit3 tests pass on macOS arm64 (net10.0), except 263 tests that fail to start `ilasm` because only the osx-x64 binary is available here. I haven't run the tests on Windows.
Fixes #67912.