[release/9.0-staging] NativeAOT/Arm64: Do not overwrite gcinfo tracking registers for TLS #112549
+18
−7
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 #112469 to release/9.0-staging
/cc @kunalspathak
Customer Impact
We were wrongly reporting certain registers has gc references which would lead the GC would interpret the values as them as valid object addresses and enumerate over them. This would lead to an undefined behavior or crash. Although it is a rare occurrence and certain events need to line up in place (method's register requirements in given method, trigger of GC at the instruction where wrong registers are tracked, etc.), it is still a potential issue because it can lead to fatal crash and diagnosing that crash would take an area expert (hard to root cause).
Regression
In #97910, we started inlining TLS access for NativeAOT for linux/arm64 and the issue was introduced since then.
Testing
The failing test was reverified and the asmdiffs were studied to make sure that we are reporting the gc references correctly.
Risk
Low. This optimization is present in our mainline for almost a year now and was found from our internal tool just recently.