Bug 16674 - Fatal crash due to ArgumentException in TaskAwaiter.HandleUnexpectedTaskResult
Summary: Fatal crash due to ArgumentException in TaskAwaiter.HandleUnexpectedTaskResult
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 7.0.4.x
Hardware: Other Other
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-12-09 09:38 UTC by Øystein Krog
Modified: 2013-12-13 19:57 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Repro (91.02 KB, application/zip)
2013-12-09 09:39 UTC, Øystein Krog
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Øystein Krog 2013-12-09 09:38:26 UTC
I've been struggling with a bug the last few weeks, and I've spent several days now narrowing it down.
The bug is very subtle, even minor "unrelated" changes "fixes" it and to make it worse I've only ever been able to produce it on real iOS devices.

Howver; I've finally got a small repro-case, which I will attach.

Here is the call stack:

Dec  9 15:31:56 Initial-Force-Ipad-Mini SingleViewTest[3688] <Warning>: Unhandled managed exception: Should never be reached (System.ArgumentException)
	  at System.Runtime.CompilerServices.TaskAwaiter.HandleUnexpectedTaskResult (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
	  at System.Runtime.CompilerServices.TaskAwaiter`1[System.Int32].GetResult () [0x00000] in <filename unknown>:0 
	  at SingleViewTest.SingleViewTestViewController+<TestC>c__async2`1[System.Object].MoveNext () [0x00000] in <filename unknown>:0 
	--- End of stack trace from previous location where exception was thrown ---
	  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
	  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
	  at SingleViewTest.SingleViewTestViewController+<TestB>c__async4.MoveNext () [0x00000] in <filename unknown>:0 
	--- End of stack trace from previous location where exception was thrown ---
	  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
	  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
	  at SingleViewTest.SingleViewTestViewController+<TestA>c__async3.MoveNext () [0x00000] in <filename unknown>:0 
	--- End of stack trace from previous location where exception was thrown ---
	  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
	  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <filename unknown>:0 
	  at SingleViewTest.SingleViewTestViewController+<Test>c__async1.MoveNext () [0x00000] in <filename unknown>:0 
	--- End of stack trace from previous location where exception was thrown ---
	  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
	  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
	  at SingleViewTest.SingleViewTestViewController+<ButtonClick>c__async0.MoveNext () [0x00000] in <filename unknown>:0 

I know there have been some task/await fixes in the latest mono master, but as there is no way for me test that code in combination with Xamarin.IOS (which quite frankly really sucks) I don't think there is any other option for be but to submit this. 
If the git fixes don't actually fix this problem we would be even further delayed in our app development, hopefully this will help to either fix the bug or you guys can confirm that the existing fixes also fixes this crash.
Comment 1 Øystein Krog 2013-12-09 09:39:06 UTC
Created attachment 5623 [details]
Repro
Comment 2 Øystein Krog 2013-12-09 09:58:47 UTC
Forgot to mention, it only triggers when using certain build options, e.g. one must use LLVM.
The Repro project will trigger the bug if you build the Ad-Hoc project and deploy to an iDevice.
I've tested on an iPad mini (old) (MD528LL/A), iPad "2" (MC774KN/A) and an iPhone 5.
Comment 3 Marek Safar 2013-12-12 09:36:04 UTC
I cannot reproduce this with master.
Comment 4 Øystein Krog 2013-12-12 09:56:12 UTC
Awesome!
I'm looking forward to seeing a new mono in the update channels :)
Comment 5 Rolf Bjarne Kvinge [MSFT] 2013-12-13 19:57:16 UTC
I can't reproduce this either, with MonoTouch 7.0.6 (which will be released soon).