This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.

Bugzilla – Bug 7965

Regression in 3.0 (System.Threading.Tasks): InvalidOperationException "The underlying Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled. IsTerminating is set to True"

Bug 7965 -Regression in 3.0 (System.Threading.Tasks): InvalidOperationException "The underlying Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled. IsTerminating is set to True"

We have detected our AcceptanceTests failing if we upgrade to Mono 3.0.
I still haven't reduced this to a simple testcase, but thought that putting
here the stacktrace early on may help somehow. BTW, we are not using any async
APIs or C#5.
[The regression is somewhere between the commit 551ca84 (labeled as "2.11.4",
but not necessarily the same tag) and the version based on the tarball found in
http://origin-download.mono-project.com/sources/mono/mono-3.0.0.tar.bz2.
Stacktrace is (caputed by xsp4):
Listening on port: 8000 (non-secure)
Hit Return to stop the server.
Handling exception type InvalidOperationException
Message is The underlying Task is already in one of the three final states:
RanToCompletion, Faulted, or Canceled.
IsTerminating is set to True
System.InvalidOperationException: The underlying Task is already in one of the
three final states: RanToCompletion, Faulted, or Canceled.
at
System.Threading.Tasks.TaskCompletionSource`1[System.Object].ThrowInvalidException
() [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskCompletionSource`1[System.Object].SetException
(IEnumerable`1 exceptions) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskCompletionSource`1[System.Object].SetException
(System.Exception exception) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskFactory`1[System.Object].InnerInvoke
(System.Threading.Tasks.TaskCompletionSource`1 tcs, System.Func`2 endMethod,
IAsyncResult l) [0x00000] in <filename unknown>:0
at
System.Threading.Tasks.TaskFactory`1+<FromAsyncBeginEnd>c__AnonStorey2D`3[System.Object,System.Byte[],System.Int32,System.Int32].<>m__33
(IAsyncResult l) [0x00000] in <filename unknown>:0
at System.Net.WebAsyncResult.CB (System.Object unused) [0x00000] in <filename
unknown>:0
Handling exception type InvalidOperationException
Message is The underlying Task is already in one of the three final states:
RanToCompletion, Faulted, or Canceled.
IsTerminating is set to True
System.InvalidOperationException: The underlying Task is already in one of the
three final states: RanToCompletion, Faulted, or Canceled.
at System.Threading.Tasks.TaskCompletionSource`1[System.Int32].SetException
(IEnumerable`1 exceptions) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskCompletionSource`1[System.Int32].SetException
(System.Exception exception) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskFactory`1[System.Int32].InnerInvoke
(System.Threading.Tasks.TaskCompletionSource`1 tcs, System.Func`2 endMethod,
IAsyncResult l) [0x00000] in <filename unknown>:0
at
System.Threading.Tasks.TaskFactory`1+<FromAsyncBeginEnd>c__AnonStorey2D`3[System.Int32,System.Byte[],System.Int32,System.Int32].<>m__33
(IAsyncResult l) [0x00000] in <filename unknown>:0
at System.Net.WebAsyncResult.CB (System.Object unused) [0x00000] in <filename
unknown>:0
Handling exception type InvalidOperationException
Message is The underlying Task is already in one of the three final states:
RanToCompletion, Faulted, or Canceled.
IsTerminating is set to True
System.InvalidOperationException: The underlying Task is already in one of the
three final states: RanToCompletion, Faulted, or Canceled.
at System.Threading.Tasks.TaskCompletionSource`1[System.Int32].SetException
(IEnumerable`1 exceptions) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskCompletionSource`1[System.Int32].SetException
(System.Exception exception) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskFactory`1[System.Int32].InnerInvoke
(System.Threading.Tasks.TaskCompletionSource`1 tcs, System.Func`2 endMethod,
IAsyncResult l) [0x00000] in <filename unknown>:0
at
System.Threading.Tasks.TaskFactory`1+<FromAsyncBeginEnd>c__AnonStorey2D`3[System.Int32,System.Byte[],System.Int32,System.Int32].<>m__33
(IAsyncResult l) [0x00000] in <filename unknown>:0
at System.Net.WebAsyncResult.CB (System.Object unused) [0x00000] in <filename
unknown>:0
PS: I recommend you to create the "3.0" version in Bugzilla :)