-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
After upgrading my iOS app from classic Xamarin.iOS to .NET7 I started observing frequent InvalidCastExeptions in my crash reporting tool (AppCenter). I haven't changed much dependency-wise and I am unable to reproduce this locally.
Reproduction Steps
Unfortunately, I don't know what part of my code causes this behavior.
For the first stack trace, I assume that my code (or some dependencies code) is creating a CancellationTokenSource with a delay parameter.
For the second stack trace below, I assume that some call to Task.Delay is causing the crash.
Expected behavior
No crash :)
Actual behavior
SIGABRT: Arg_InvalidCastException
System.Threading.CancellationTokenSource.TimerCallback(Object )
System.Threading.TimerQueueTimer.CallCallback(Boolean )
System.Threading.TimerQueueTimer.Fire(Boolean )
System.Threading.TimerQueue.FireNextTimers()
System.Threading.TimerQueue.System.Threading.IThreadPoolWorkItem.Execute()
System.Threading.ThreadPoolWorkQueue.DispatchItemWithAutoreleasePool(Object , Thread )
this is here:
runtime/src/libraries/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs
Line 35 in 215b39a
| ((CancellationTokenSource)state!).NotifyCancellation(throwOnFirstException: false); // skip ThrowIfDisposed() check in Cancel() |
SIGABRT: Arg_InvalidCastException
System.Threading.Tasks.Task.DelayPromise.TimerCallback(Object )
System.Threading.TimerQueueTimer.CallCallback(Boolean )
System.Threading.TimerQueueTimer.Fire(Boolean )
System.Threading.TimerQueue.FireNextTimers()
System.Threading.TimerQueue.System.Threading.IThreadPoolWorkItem.Execute()
System.Threading.ThreadPoolWorkQueue.DispatchItemWithAutoreleasePool(Object , Thread )
this is here:
runtime/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
Line 5632 in 26b58b9
| private static void TimerCallback(object? state) => ((DelayPromise)state!).CompleteTimedOut(); |
Both crashes originate from here:
| _timerCallback(_state); |
The "_state" variable is nullable, and based on the reports, the crashes are caused by the variable to be indeed null.
Regression?
I did not see those crashes when using "old" Xamarin.iOS
Known Workarounds
No response
Configuration
.net7-ios
happens on various iPhone models and iOS versions
Other information
No response