Skip to content

[net9] System.Private.CoreLib occurs InvalidOperationException and InvalidCastException #114262

@sleushunou

Description

@sleushunou

Description

reproduces absolutely randomly both in debug and in release mode, appeared after switching from net8-ios to net9-ios (It doesn't seem like it applies to iOS)

stacktrace of InvalidCastException:

System.InvalidCastException: Specified cast is not valid.
at System.Threading.Tasks.Task.RunContinuations(Object continuationObject)
at System.Threading.Tasks.Task.FinishContinuations()
at System.Threading.Tasks.Task.FinishStageThree()
at System.Threading.Tasks.Task.FinishStageTwo()
at System.Threading.Tasks.Task.FinishSlow(Boolean userDelegateExecute)
at System.Threading.Tasks.Task.Finish(Boolean userDelegateExecute)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
at System.Threading.Tasks.Task.ExecuteEntryUnsafe(Thread threadPoolThread)
at System.Threading.Tasks.Task.ExecuteFromThreadPool(Thread threadPoolThread)
at System.Threading.ThreadPoolWorkQueue.DispatchItemWithAutoreleasePool(Object workItem, Thread currentThread)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()

stacktrace of InvalidOperationException (from Sentry):

System.InvalidOperationException: Arg_InvalidOperationException
?, in void ManualResetValueTaskSourceCore.SignalCompletion()
?, in void ManualResetValueTaskSourceCore.SetResult(long)
?, in void ThreadPoolValueTaskSource.ExecuteInternal()
?, in void ThreadPoolValueTaskSource.System.Threading.IThreadPoolWorkItem.Execute()
?, in void ThreadPoolWorkQueue.DispatchItemWithAutoreleasePool(object, Thread)
?, in bool ThreadPoolWorkQueue.Dispatch()
?, in void WorkerThread.WorkerThreadStart()

also screenshot from debug session (from AppDomain.CurrentDomain.UnhandledException):

Image

Reproduction Steps

have not steps

Expected behavior

no crashes

Actual behavior

crash occurs

Regression?

works in net8-ios

Known Workarounds

No response

Configuration

net9, ios 18

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions