Our automatic bug reporting tool has picked up a very odd exception related to Task.ContinueWith. Log history shows affected users (only 14 total in one month) are in different areas of the program when this occurs, and looking at the stack trace I'm really doubtful the issue is in our code. The stack trace is as follows:
NullReferenceException Object reference not set to an instance of an object.
<00000000000000000000000000000000> System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke()
<00000000000000000000000000000000> System.Threading.Tasks.Task.Execute()
<00000000000000000000000000000000> System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
<00000000000000000000000000000000> System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task& currentTaskSlot)
<00000000000000000000000000000000> System.Threading.Tasks.Task.ExecuteEntry(System.Boolean bPreventDoubleExecution)
<00000000000000000000000000000000> System.Threading.ThreadPoolWorkQueue.Dispatch()
unknown Rethrow as AggregateException: A Task's exception(s)
unknown System.Threading.Tasks.TaskExceptionHolder:Finalize()
Looking at the source code for the ContinuationTaskFromResultTask.InnerInvoke() method, it looks like the only way this can throw a NullReferenceException is if the local antecedent field was null. Even then, the Contract.Assert method should be throwing a different exception.
Has anyone seen this before or know how this might occur?
Thank you