dotnet / dotnet/wpf

NullReferenceException in BindingExpressionBase

Open
#10,412 2 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

Hard to reproduce. Occurred when running `.NET 8.0.8`.

Under certain circumstances, `notifyDataErrors` is `null` here (from what I can tell): https://github.com/dotnet/wpf/blob/bc243c8c5fee1a19216b58b234310cf76f3f843b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpressionBase.cs#L2313

```
> PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.UpdateNotifyDataErrorValidationErrors(System.Collections.Generic.List errors) Line 1758 C#
PresentationFramework.dll!System.Windows.Data.BindingExpression.UpdateNotifyDataErrors(System.ComponentModel.INotifyDataErrorInfo indei, string propertyName, object value) Line 1641 C#
PresentationFramework.dll!System.Windows.Data.BindingExpression.OnErrorsChanged.AnonymousMethod__108_0(object arg) Line 1798 C#
PresentationFramework.dll!MS.Internal.Data.DataBindEngine.ProcessCrossThreadRequests() Line 501 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 59 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Line 24 C#
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() Line 424 C#
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(object obj) Line 99 C#
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 179 C#
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 85 C#
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() Line 350 C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() Line 1250 C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(nint hwnd, int msg, nint wParam, nint lParam, ref bool handled) Line 1367 C#
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(nint hwnd, int msg, nint wParam, nint lParam, ref bool handled) Line 212 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 73 C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Line 24 C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Line 990 C#
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(nint hwnd, int msg, nint wParam, nint lParam) Line 180 C#
[Native to Managed Transition]
[Managed to Native Transition]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Line 1281 C#
PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) Line 1539 C#
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) Line 1214 C#

```

![Image](https://github.com/user-attachments/assets/60377815-8093-44f3-9688-3ea44a95da5b)

### Reproduction Steps

Hard to reproduce. Happens intermittently.

### Expected behavior

Should not throw `NullReferefenceException`.

### Actual behavior

A gazillion `NullReferefenceException` are thrown.

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.