Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race conditions in attribute asserts (#52486)
* Fix race conditions in attribute asserts There are asserts in our `CustomAttributeBag` to verify we maintain the invariant that early decoding occurs before the full decoding. The asserts though done in the getters and take the following form: ```cs bool earlyComplete = IsPartComplete(CustomAttributeBagCompletionPart.EarlyDecodedWellKnownAttributeData); // If late attributes are complete, early attributes must also be complete Debug.Assert(!IsPartComplete(CustomAttributeBagCompletionPart.DecodedWellKnownAttributeData) || earlyComplete); return earlyComplete; ``` This pattern is subject to race conditions. Consider the case where the `bool earlyComplete` statement runs to completion and returns `false`. Then another thread swaps in and completes both early and full decoding. At that point the original thread resumes and the `Debug.Assert` will fail yet no invariant has been violated. Moved the `Debug.Assert` into the setters where we can reliably test the state invariants. closes #52372 related to #52368 * Fix * Add back an assert
- Loading branch information