Repository navigation
Fix assert in NativeAOT when handling data flow on compiler generated… - #73085
Merged
Merged
Conversation
… code. The problem occurs when an entire type/assembly is preserved through explicit rooting (command line, rd.xml, ...). If such type contains a local function (for example) which is only called from a branch which is going to be removed by constant-prop/branch removal the internal tracking of compiler generated methods will see this local function as orphaned (not belonging to any user method). This leads to a case where we will try to run data flow on the local function - but that should never happen for compiler generated methods directly -> assert. The fix is (just like in the linker), to never run data flow on compiler generated methods directly - they should only run data flow as part of their respective user method. Fixes dotnet#73027
MichalStrehovsky
approved these changes
Jul 30, 2022
MichalStrehovsky
left a comment
Member
There was a problem hiding this comment.
Another possible fix would be to not use ILProvider, but EcmaMethodIL.Create directly - that one sees untransformed IL before constprop. I could see that having both advantages and disadvantages.
| methodILDefinition = FlowAnnotations.ILProvider.GetMethodIL(userMethod); | ||
| } | ||
|
|
||
| // Data-flow (reflection scanning) for compiler-generated methods will happen as part of the |
Member
There was a problem hiding this comment.
I only understood what's going on after re-reading the pull request description - could you add a sentence describing when this can happen (the lines before this are supposed to do this conversion to user code).
Member
|
Merging because I'm running into this in #69108 and can't get a checked build of anything without this fix. We need to add checked test coverage to the CI matrix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… code.
The problem occurs when an entire type/assembly is preserved through explicit rooting (command line, rd.xml, ...). If such type contains a local function (for example) which is only called from a branch which is going to be removed by constant-prop/branch removal the internal tracking of compiler generated methods will see this local function as orphaned (not belonging to any user method). This leads to a case where we will try to run data flow on the local function - but that should never happen for compiler generated methods directly -> assert.
The fix is (just like in the linker), to never run data flow on compiler generated methods directly - they should only run data flow as part of their respective user method.
Fixes #73027