Bug 44605 - "Stop Debugging" command causes iOS apps to crash with "Assertion at ... debugger-agent.c... condition `flags == 0' not met" rather than exiting gracefully
Summary: "Stop Debugging" command causes iOS apps to crash with "Assertion at ... debu...
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: XMA ()
Version: 4.2.0 (C8)
Hardware: PC Windows
: --- major
Target Milestone: 4.3.0 (C9)
Assignee: Emanuel
URL:
Depends on:
Blocks:
 
Reported: 2016-09-22 03:02 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-12-02 14:33 UTC (History)
3 users (show)

Tags: BZRC6SR4S1_C5SR5S1
Is this bug a regression?: Yes
Last known good build: Cycle 5 SR 5


Attachments
Template Cycle 5 iPad project, for reference (8.33 KB, application/zip)
2016-09-22 03:02 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
IDE, build, and device logs and IDE version info (203.15 KB, application/zip)
2016-09-22 03:04 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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 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:
VERIFIED FIXED

Description Brendan Zagaeski (Xamarin Team, assistant) 2016-09-22 03:02:10 UTC
Created attachment 17660 [details]
Template Cycle 5 iPad project, for reference

"Stop Debugging" command causes iOS apps to crash with "Assertion at ... debugger-agent.c... condition `flags == 0' not met" rather than exiting gracefully


One ugly thing this does is fill up the device with crash logs during just any old start-and-stop debugging of an app.


Taking into consideration my observations on Bug 43929, I also have a hunch that this underlying issue might somehow account for a new cluster of bugs reported against Cycle 8: Bug 44567, Bug 44578, Bug 44301.  My (wild) guess is that some timing or conditional logic might have changed in Cycle 8 in such a way that this failed assertion is now being triggered in certain environments at the _start_ of debugging rather than at the end of debugging.




## Regression status: The problem first appeared between Cycle 5 SR 5 and Cycle 6 SR 4

> BAD  Cycle 8      + iOS 10.0.1 device. XamarinVS 4.2.0.680   (c4382f5) + Xamarin.iOS 10.0.0.6  (6c3fee4) + Mono 4.6.0 (746756c) + Xcode 8.0, 8A218a
> BAD  Cycle 8      + iOS 8.0    device. XamarinVS 4.2.0.680   (c4382f5) + Xamarin.iOS 10.0.0.6  (6c3fee4) + Mono 4.6.0 (746756c) + Xcode 8.0, 8A218a

> BAD  Cycle 7      + iOS 8.0    device. XamarinVS 4.1.0.530   (2e39740) + Xamarin.iOS 9.8.0.323 (39ebb77) + Mono 4.4.0 (5995f74) + Xcode 7.3, 7D175

> BAD  Cycle 6 SR 4 + iOS 8.0    device. XamarinVS 4.0.4.4     (a9c7826) + Xamarin.iOS 9.6.2.4   (d8bedd0) + Mono 4.2.4 (71b88f3) + Xcode 7.3, 7D175

> GOOD Cycle 5 SR 5 + iOS 8.0    device. XamarinVS 3.11.1594.0 (a06d6d5) + Xamarin.iOS 9.1.0.27  (1f068b4) + Mono 4.0.5 (1d8d582) + Xcode 7.3, 7D175
> GOOD Cycle 5 SR 5 + iOS 8.0    device. XamarinVS 3.11.1594.0 (a06d6d5) + Xamarin.iOS 9.1.0.27  (1f068b4) + Mono 4.0.5 (1d8d582) + Xcode 6.4, 6E35b



## Steps to replicate

1. Create a new "Visual C# > iOS > iPad > Single View App (iPad)" or "Visual C# > iOS > iPhone > Single View App (iPhone)" project.  (I have also a attached a sample iPad project created using Cycle 5 SR 5 that I used for some of my tests.)

2. If needed for the current test device, edit the `Info.plist` to set the deployment target to 8.0 or lower.

3. Select "Debug > Start Debugging" to build and run the project on device in the "Debug|iPhone" configuration.

4. After the app launches successfully, select "Debug > Stop Debugging".




## BAD Results

The app exits due to a crash rather than exiting gracefully.



### The iOS device system log shows a failed assertion, followed by a stack trace, and then a message indicating that the app has crashed

> * Assertion at /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/mono/mono/mini/debugger-agent.c:9864, condition `flags == 0' not met
...
> Application 'UIKitApplication:com.your-company.UnifiedSingleViewIpadC5[0x46e7]' crashed.



## GOOD Results (with Cycle 5 SR 5)

_When_ it stops the app successfully, C5SR5 produces a more graceful exit.  The device logs show something "nice" like:
> Application 'UIKitApplication:com.your-company.UnifiedSingleViewIpad1[0xf3bb]' exited voluntarily.

But I should probably also note that the old build host in C5SR5 had issues with consistently quitting the app on every debugging attempt, so it did sometimes take me a couple redeploy attempts to get the IDE to close the app as expected with the "Stop Debugging" command.




## GOOD Results (with Cycle 8 Xamarin Studio 6.1 on Mac)

The device logs show the "nice" message as in C5SR5 XamarinVS:
> Application 'UIKitApplication:com.your-company.UnifiedSingleViewIpadC5[0x13e5]' exited 



## Additional environment info


### Devices tested

iPhone 6s Plus, iOS 10.0.1 (14A403), English/USA locale
iPad Mini 2, iOS 8.0 (12A365), English/USA locale


### Windows

Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3

Windows 10 Version 10.0 (Build 10240), English/USA locale


### Mac

OS X 10.11.6, English/USA locale
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2016-09-22 03:04:55 UTC
Created attachment 17661 [details]
IDE, build, and device logs and IDE version info
Comment 2 xamarin-release-manager 2016-11-22 13:29:26 UTC
Fixed in version 99.1.0.126 (master)

Author: Emanuel
Commit: bd6a3995f2c45e2efb71e064c351d43432c45c81 (xamarin/XamarinVS)
Comment 3 xamarin-release-manager 2016-11-22 14:21:58 UTC
Fixed in version 4.3.0.320 (cycle9)

Author: Emanuel
Commit: 9e2570764f745fd3ff85b5bd4bd104a35cfa7988 (xamarin/XamarinVS)