Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid ECMA spec violation in PropertyStore #12956

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

JeremyKuhne
Copy link
Member

@JeremyKuhne JeremyKuhne commented Feb 14, 2025

The manual unboxing we were doing was not an ECMA approved use of the instruction. As such it could potentially fail in the future should the runtime decide to break the way we were using it.

One way to fix this would be to set each of the fields individually on the unboxed ref as the current two types we're optimizing are mutable. I've instead used StrongBox<T>. While significantly more complicated, it will not run afoul of the ECMA spec should we get an immutable type we want to handle.

If performance here ever ends up being a problem we could go the other way.

Fixes #12933

Microsoft Reviewers: Open in CodeFlow

The manual unboxing we were doing was not an ECMA approved use of the instruction. As such it could potentially fail in the future should the runtime decide to break the way we were using it.

One way to fix this would be to set each of the fields individually on the unboxed ref as the current two types we're optimizing are mutable. I've instead used `StrongBox<T>`. While significantly more complicated, it will not run afoul of the ECMA spec should we get an immutable type we want to handle.

If performance here ever ends up being a problem we could go the other way.

Fixes dotnet#12933
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.97821%. Comparing base (865c506) to head (5744f1d).
Report is 3 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #12956         +/-   ##
===================================================
- Coverage   75.98280%   75.97821%   -0.00459%     
===================================================
  Files           3265        3265                 
  Lines         643289      643295          +6     
  Branches       47426       47428          +2     
===================================================
- Hits          488789      488764         -25     
- Misses        150950      150964         +14     
- Partials        3550        3567         +17     
Flag Coverage Δ
Debug 75.97821% <100.00000%> (-0.00459%) ⬇️
integration 18.01635% <93.33333%> (+0.01046%) ⬆️
production 49.87457% <100.00000%> (-0.00873%) ⬇️
test 96.95308% <ø> (-0.00084%) ⬇️
unit 47.33450% <100.00000%> (+0.01993%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@JeremyKuhne JeremyKuhne merged commit b0c9350 into dotnet:main Feb 15, 2025
8 checks passed
@JeremyKuhne JeremyKuhne deleted the fix12933 branch February 15, 2025 02:09
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0 Preview2 milestone Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Illegal use of Unsafe.Unbox<T> in PropertyStore.cs
2 participants