[release/10.0] JIT: SpanHelpers.Fill may escape its last argument #122919
+57
−1
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.
Backport of #122902 to release/10.0
/cc @AndyAyersMS
Customer Impact
Customer reported in #122879
Silent bad code in some cases involving calls to
SpanHelpers.Fillwhere the fill value is a GC ref coming from a locally allocated object.Regression
This is a bug in a new optimization in .NET 10.
Testing
Verified fix on customer reported case; also added this as regression test. Bug was an oversight; the first argument to
SpanHelpers.Filldoes not escape, but the other two might. The JIT was assuming none of the arguments escaped.Risk
Low, we now disable stack allocation in this case.