We are building a WPF app and are seeing some random and very strange behavior which seems to originate from within the BCL. We are catching an unhandled exception with the following stacktrace:
[ArgumentException],
"TimeSpan does not accept floating point Not-a-Number values."
at System.TimeSpan.Interval(Double value, Int32 scale)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
Now, if we are to believe Reflector the calling method (Dispatcher.Invoke) calls
...,TimeSpan.FromSeconds(-1.0),...
which throws an Argument exception because the argument being passed in returns true on double.IsNaN. This is clearly not making any sense and we find this very puzzling, to say the least.
We have been unable to reproduce this behavior in any smaller samples, so we are looking for ways to determine the cause of this (and other seemingly related TimeSpan exceptions which are also thrown) in our full app. We have a number of questions they we hope someone can help us with, as we have had no luck in googling for anything like this
- Has anybody seen such behavior or recognize the symptoms
- What causes these seemingly random behavior in basic math, are we somehow corrupting the stack or heap?
- Can we somehow debug the IL in TimeSpan.Interval (WinDbg perhaps?) and break and inspect the stack/heap to verify the values?
Our application is quite data heavy, with lots of data being fetched async and lots of data binding, but we see no smoking gun pointing at any of this from the stack traces we have been able to obtain.
Just to clarify the question: Has anybody seen the described behavior before, recognizes the symptoms or has input as to how we can debug the situation?
Thoughts, comments, ideas, suggestions?