Repository navigation
Fix race in WeakEventProxy field access - #37568
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37568Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37568" |
|
Hey there @@baaaaif! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Hey there @baaaaif! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
kubaflo
left a comment
There was a problem hiding this comment.
Capturing the weak-reference fields in locals makes each check/use operate on a single reference. This closes the race where Unsubscribe() can null the field between the two field reads, while preserving the existing weak-reference semantics. The linked TryGetSource/TryGetHandler stack traces are consistent with this failure. Looks good to me.
### Description of Change Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with `Unsubscribe()`, which clears the fields concurrently. The race has been observed as an unhandled Android `NullReferenceException` from both `TryGetSource` during binding finalization and `TryGetHandler` while processing property changes. ### Issues Fixed Fixes #32602 ### Validation - `dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
### Description of Change Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with `Unsubscribe()`, which clears the fields concurrently. The race has been observed as an unhandled Android `NullReferenceException` from both `TryGetSource` during binding finalization and `TryGetHandler` while processing property changes. ### Issues Fixed Fixes #32602 ### Validation - `dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
### Description of Change Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with `Unsubscribe()`, which clears the fields concurrently. The race has been observed as an unhandled Android `NullReferenceException` from both `TryGetSource` during binding finalization and `TryGetHandler` while processing property changes. ### Issues Fixed Fixes #32602 ### Validation - `dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
### Description of Change Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with `Unsubscribe()`, which clears the fields concurrently. The race has been observed as an unhandled Android `NullReferenceException` from both `TryGetSource` during binding finalization and `TryGetHandler` while processing property changes. ### Issues Fixed Fixes #32602 ### Validation - `dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
### Description of Change Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with `Unsubscribe()`, which clears the fields concurrently. The race has been observed as an unhandled Android `NullReferenceException` from both `TryGetSource` during binding finalization and `TryGetHandler` while processing property changes. ### Issues Fixed Fixes #32602 ### Validation - `dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
### Description of Change Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with `Unsubscribe()`, which clears the fields concurrently. The race has been observed as an unhandled Android `NullReferenceException` from both `TryGetSource` during binding finalization and `TryGetHandler` while processing property changes. ### Issues Fixed Fixes #32602 ### Validation - `dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
### Description of Change Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with `Unsubscribe()`, which clears the fields concurrently. The race has been observed as an unhandled Android `NullReferenceException` from both `TryGetSource` during binding finalization and `TryGetHandler` while processing property changes. ### Issues Fixed Fixes #32602 ### Validation - `dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
### Description of Change Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with `Unsubscribe()`, which clears the fields concurrently. The race has been observed as an unhandled Android `NullReferenceException` from both `TryGetSource` during binding finalization and `TryGetHandler` while processing property changes. ### Issues Fixed Fixes #32602 ### Validation - `dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
### Description of Change Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with `Unsubscribe()`, which clears the fields concurrently. The race has been observed as an unhandled Android `NullReferenceException` from both `TryGetSource` during binding finalization and `TryGetHandler` while processing property changes. ### Issues Fixed Fixes #32602 ### Validation - `dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0` Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Description of Change
Captures the weak-reference fields in local variables before testing and dereferencing them. This closes the time-of-check/time-of-use race with
Unsubscribe(), which clears the fields concurrently.The race has been observed as an unhandled Android
NullReferenceExceptionfrom bothTryGetSourceduring binding finalization andTryGetHandlerwhile processing property changes.Issues Fixed
Fixes #32602
Validation
dotnet build src/Controls/src/Core/Controls.Core.csproj --no-restore --verbosity minimal -p:TargetFramework=netstandard2.0