Bug 32549 - DisplayAlert crashing app
Summary: DisplayAlert crashing app
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 1.4.4
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-07-28 19:27 UTC by Paul Johnson
Modified: 2015-07-29 07:50 UTC (History)
1 user (show)

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

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 ANSWERED

Description Paul Johnson 2015-07-28 19:27:27 UTC
I have a very simple line of code which is killing my iOS app every time it's used

await DisplayAlert("Fail", string.Format("The server fell over with the following error - {0}. Please check and resend", data), "OK);

When the alert line comes to execute, the app falls over with the following throwback

2015-07-29 00:22:31.379 insuranceiOS[1041:1611399] Unhandled managed exception:
Argument cannot be null.
Parameter name: cancel (System.ArgumentNullException)
  at Xamarin.Forms.Page.DisplayAlert (System.String title, System.String message, System.String accept, System.String cancel) [0x00009] in <filename unknown>:0 
  at insurance.Login+<LoginUser>c__async0.MoveNext () [0x00115] in /Users/PFJ/Developer/insurance/insurance/UI/Login.cs:120 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/1977/7cf6633a/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /Users/builder/data/lanes/1977/7cf6633a/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1006 
  at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/1977/7cf6633a/source/maccore/src/UIKit/UIKitSynchronizationContext.cs:24 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/1977/7cf6633a/source/maccore/src/Foundation/NSAction.cs:164 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/1977/7cf6633a/source/maccore/src/UIKit/UIApplication.cs:63 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0001c] in /Users/builder/data/lanes/1977/7cf6633a/source/maccore/src/UIKit/UIApplication.cs:46 
  at insurance.iOS.Application.Main (System.String[] args) [0x00008] in /Users/PFJ/Developer/insurance/iOS/Main.cs:17 
2015-07-29 00:22:31.381 insuranceiOS[1041:1611399] critical: Stacktrace:

2015-07-29 00:22:31.382 insuranceiOS[1041:1611399] critical: 
Native stacktrace:

2015-07-29 00:22:31.527 insuranceiOS[1041:1611399] critical: 	0   insuranceiOS                        0x0000000100c88030 mono_handle_native_sigsegv + 264
2015-07-29 00:22:31.527 insuranceiOS[1041:1611399] critical: 	1   libsystem_platform.dylib            0x0000000196ffc95c _sigtramp + 68
2015-07-29 00:22:31.528 insuranceiOS[1041:1611399] critical: 	2   libsystem_pthread.dylib             0x0000000197005170 pthread_kill + 112
2015-07-29 00:22:31.528 insuranceiOS[1041:1611399] critical: 	3   libsystem_c.dylib                   0x0000000196edeb18 abort + 112
2015-07-29 00:22:31.528 insuranceiOS[1041:1611399] critical: 	4   insuranceiOS                        0x0000000100d5584c print_exception + 0
2015-07-29 00:22:31.528 insuranceiOS[1041:1611399] critical: 	5   insuranceiOS                        0x0000000100c886b0 mono_invoke_unhandled_exception_hook + 96
2015-07-29 00:22:31.528 insuranceiOS[1041:1611399] critical: 	6   insuranceiOS                        0x0000000100c87e40 mono_handle_exception_internal + 4408
2015-07-29 00:22:31.529 insuranceiOS[1041:1611399] critical: 	7   insuranceiOS                        0x0000000100c86cfc mono_handle_exception + 40
2015-07-29 00:22:31.529 insuranceiOS[1041:1611399] critical: 	8   insuranceiOS                        0x0000000100c80a54 mono_arm_throw_exception + 152
2015-07-29 00:22:31.529 insuranceiOS[1041:1611399] critical: 	9   insuranceiOS                        0x000000010032c6e8 throw_exception + 136
2015-07-29 00:22:31.529 insuranceiOS[1041:1611399] critical: 	10  insuranceiOS                        0x000000010022fadc System_Runtime_ExceptionServices_ExceptionDispatchInfo_Throw + 44
2015-07-29 00:22:31.529 insuranceiOS[1041:1611399] critical: 	11  insuranceiOS                        0x00000001001912c0 System_Runtime_CompilerServices_AsyncMethodBuilderCore__ThrowAsyncm__0_object + 80
2015-07-29 00:22:31.530 insuranceiOS[1041:1611399] critical: 	12  insuranceiOS                        0x00000001000a8fc8 UIKit_UIKitSynchronizationContext__Postc__AnonStorey0__m__0 + 40
2015-07-29 00:22:31.530 insuranceiOS[1041:1611399] critical: 	13  insuranceiOS                        0x0000000100081254 Foundation_NSAsyncActionDispatcher_Apply + 36
2015-07-29 00:22:31.530 insuranceiOS[1041:1611399] critical: 	14  insuranceiOS                        0x00000001002f7684 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244
2015-07-29 00:22:31.530 insuranceiOS[1041:1611399] critical: 	15  insuranceiOS                        0x0000000100c94628 mono_jit_runtime_invoke + 1260
2015-07-29 00:22:31.530 insuranceiOS[1041:1611399] critical: 	16  insuranceiOS                        0x0000000100ce7248 mono_runtime_invoke + 128
2015-07-29 00:22:31.531 insuranceiOS[1041:1611399] critical: 	17  insuranceiOS                        0x0000000100c47b64 native_to_managed_trampoline_5 + 208
2015-07-29 00:22:31.531 insuranceiOS[1041:1611399] critical: 	18  insuranceiOS                        0x0000000100c4f3f4 -[__MonoMac_NSAsyncActionDispatcher xamarinApplySelector] + 60
2015-07-29 00:22:31.531 insuranceiOS[1041:1611399] critical: 	19  Foundation                          0x00000001859d1f9c <redacted> + 372
2015-07-29 00:22:31.531 insuranceiOS[1041:1611399] critical: 	20  CoreFoundation                      0x0000000184a88240 <redacted> + 24
2015-07-29 00:22:31.531 insuranceiOS[1041:1611399] critical: 	21  CoreFoundation                      0x0000000184a874e4 <redacted> + 264
2015-07-29 00:22:31.532 insuranceiOS[1041:1611399] critical: 	22  CoreFoundation                      0x0000000184a85594 <redacted> + 712
2015-07-29 00:22:31.532 insuranceiOS[1041:1611399] critical: 	23  CoreFoundation                      0x00000001849b12d4 CFRunLoopRunSpecific + 396
2015-07-29 00:22:31.532 insuranceiOS[1041:1611399] critical: 	24  GraphicsServices                    0x000000018e4076fc GSEventRunModal + 168
2015-07-29 00:22:31.532 insuranceiOS[1041:1611399] critical: 	25  UIKit                               0x00000001895aef40 UIApplicationMain + 1488
2015-07-29 00:22:31.532 insuranceiOS[1041:1611399] critical: 	26  insuranceiOS                        0x000000010010c88c wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 348
2015-07-29 00:22:31.533 insuranceiOS[1041:1611399] critical: 	27  insuranceiOS                        0x000000010009d26c UIKit_UIApplication_Main_string___intptr_intptr + 44
2015-07-29 00:22:31.533 insuranceiOS[1041:1611399] critical: 	28  insuranceiOS                        0x000000010009d22c UIKit_UIApplication_Main_string___string_string + 172
2015-07-29 00:22:31.533 insuranceiOS[1041:1611399] critical: 	29  insuranceiOS                        0x000000010006411c insurance_iOS_Application_Main_string__ + 156
2015-07-29 00:22:31.533 insuranceiOS[1041:1611399] critical: 	30  insuranceiOS                        0x00000001002f7684 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244
2015-07-29 00:22:31.533 insuranceiOS[1041:1611399] critical: 	31  insuranceiOS                        0x0000000100c94628 mono_jit_runtime_invoke + 1260
2015-07-29 00:22:31.533 insuranceiOS[1041:1611399] critical: 	32  insuranceiOS                        0x0000000100ce7248 mono_runtime_invoke + 128
2015-07-29 00:22:31.534 insuranceiOS[1041:1611399] critical: 	33  insuranceiOS                        0x0000000100ceb4e8 mono_runtime_exec_main + 404
2015-07-29 00:22:31.534 insuranceiOS[1041:1611399] critical: 	34  insuranceiOS                        0x0000000100d53774 xamarin_main + 1844
2015-07-29 00:22:31.534 insuranceiOS[1041:1611399] critical: 	35  insuranceiOS                        0x0000000100c5bb90 main + 96
2015-07-29 00:22:31.534 insuranceiOS[1041:1611399] critical: 	36  libdyld.dylib                       0x0000000196e4ea08 <redacted> + 4
2015-07-29 00:22:31.534 insuranceiOS[1041:1611399] critical: 
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

I have also tried

await DisplayAlert("Fail", string.Format("The server fell over with the following error - {0}. Please check and resend", data), "OK, string.Empty);

but get the same result.
Comment 1 Stephane Delcroix 2015-07-29 07:50:10 UTC
The argument 'cancel' in either

    public Task DisplayAlert (string title, string message, string cancel);

or 

    public Task<bool> DisplayAlert (string title, string message, string accept, string cancel);

is required to be non-null AND not an empty string.

That's why your second call fails:

    await DisplayAlert("Fail", string.Format("The server fell over with the following error - {0}. Please check and resend", data), "OK, string.Empty);

(I guess this is not really code, as it probably does not parse at all)

About your first call:

    await DisplayAlert("Fail", string.Format("The server fell over with the following error - {0}. Please check and resend", data), "OK);

I don't know what to say or think, as it contains obvious syntax error (too). You mean either

    "", OK

or

    "OK"

or

    OK

and some of those will fail if OK is a property, a variable, or a field that is null or empty.

I'm closing this as ANSWERED. Feel free to REOPEN it with an attached sample if this answer is not helping.

Warm regards,

the XF team