Bug 28739 - AddressBook.ABPerson.GetEmails() crash with 8.10
Summary: AddressBook.ABPerson.GetEmails() crash with 8.10
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.10
Hardware: PC Windows
: High major
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
: 29392 ()
Depends on:
Reported: 2015-04-03 11:18 UTC by softlion
Modified: 2015-06-09 05:54 UTC (History)
10 users (show)

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:

Description softlion 2015-04-03 11:18:12 UTC
tested on simulator ios 8.2 / iphone 5s
same code works on 8.8.0 (beta channel)


            var contactPicker = new AsyncPeoplePicker();
            var props = contactPicker.PickerController.DisplayedProperties;

            var contact = await contactPicker.SelectPersonAsync(this);
            var emails = contact.GetEmails(); //crash here


critical: Stacktrace:
critical:   at <unknown> <0xffffffff>
critical:   at (wrapper managed-to-native) AddressBook.ABRecord.ABRecordCopyValue (intptr,int) <IL 0x0002e, 0xffffffff>
critical:   at AddressBook.ABRecord.CopyValue (int) [0x00000] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/AddressBook/ABRecord.cs:190
critical:   at AddressBook.ABPerson.GetEmails () [0x00000] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/AddressBook/ABPerson.cs:798
Comment 1 Sebastien Pouliot 2015-04-03 14:16:36 UTC
>            var contact = await contactPicker.SelectPersonAsync(this);

this is  not an API from XI. It looks like the returned `contact` is not correct and that's the cause of the crash (stack trace). However the real problem occurred before.

Can you give us a more complete test case so we can reproduce this ?
Comment 2 softlion 2015-04-03 20:22:01 UTC
Yes i can create a test case.

I confirm that going back on beta channel fix the problem on the same simulator.

So it is a problem in alpha channel somewhere.
Comment 3 softlion 2015-04-03 20:23:09 UTC
Note that I selected the first default contact in the simulator address book after a "reset simulator".
Comment 4 Sebastien Pouliot 2015-04-06 10:51:04 UTC
There was no real changes in 8.10 wrt AddressBook, so I kind of suspect it's related to the async support (which comes from mono and has a lot of changes as we move to use more code from MS reference sources). That's why the test case is needed (since it's the only way we can confirm this).
Comment 5 Sebastien Pouliot 2015-04-20 15:56:19 UTC
@softlion can you tell us if you're still seeing this issue with the newer beta build ?

I did not see similar bug reports and we do not have any code (in our test suite and samples) that produced anything similar. If it still happens then we would very much appreciate a self contained test case to diagnose this asap. Thanks!
Comment 6 softlion 2015-04-21 00:50:24 UTC
I Will try today a i dont want this version to become live with this problem. Each try costs me 2 hours so you understand that I can not do that everyday.
Comment 7 softlion 2015-04-21 05:04:09 UTC
With beta version:
- Xamarin iOS DocSync: stuck on "Finished Merging and Copy".
- Build from VS: completly freeze the UI during the build.
- still crashing

Apr 21 11:02:39 critical: Stacktrace:
Apr 21 11:02:39 critical:   at <unknown> <0xffffffff>
Apr 21 11:02:39 critical:   at (wrapper managed-to-native) AddressBook.ABRecord.ABRecordCopyValue (intptr,int) <IL 0x0002e, 0xffffffff>
Apr 21 11:02:39 critical:   at AddressBook.ABRecord.CopyValue (int) [0x00000] in /Users/builder/data/lanes/1503/c2c00129/source/maccore/src/AddressBook/ABRecord.cs:190
Apr 21 11:02:39 critical:   at AddressBook.ABPerson.GetEmails () [0x00000] in /Users/builder/data/lanes/1503/c2c00129/source/maccore/src/AddressBook/ABPerson.cs:798

Building repro demo app. Let me 1h.
Comment 10 Sebastien Pouliot 2015-04-21 08:33:36 UTC
@Ian parts of comment #7 and #8 seems to show some issues with XVS . Are you aware of them ?if not can you have someone verify them (and maybe open a separate bug report to track them). Thanks!
Comment 11 Sebastien Pouliot 2015-04-21 08:56:08 UTC
I don't always get the full stack trace [1] but a large part of it comes from new code in mono 4.0 (shipped in XI 8.10 BCL) that comes from, or was modified for, MS reference sources.

@Marek have you seen this before ?

The XI specific code (for AddressBook[UI]) did not change in 8.10.

[1] https://gist.githubusercontent.com/spouliot/2f6b2af61b057ee9d439/raw/a1e0cb3a6f08f5b2ef5f9621dd8a4128da674040/gistfile1.txt
Comment 12 Sebastien Pouliot 2015-04-21 09:10:27 UTC
Using maccore/master (same mono revision as 8.10):

* it does work (i.e. no crash) on device (armv7 and arm64);

* it does NOT work on simulators (either i386 or x86_64)
Comment 13 Sebastien Pouliot 2015-04-21 09:18:06 UTC
@Zoltan can you have a look too ?

CoreSimulator 117.15 - Device: iPhone 4s - Runtime: iOS 8.2 (12D508) - DeviceType: iPhone 4s

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x07b1269a __pthread_kill + 10
1   libsystem_pthread.dylib       	0x07b40f19 pthread_kill + 101
2   libsystem_sim_c.dylib         	0x078caa5a abort + 156
3   com.your-company.AppBugXam    	0x0013db01 mono_handle_native_sigsegv + 705
4   com.your-company.AppBugXam    	0x000d3855 mono_arch_handle_altstack_exception + 165
5   com.your-company.AppBugXam    	0x0016a770 mono_sigsegv_signal_handler + 432
6   libsystem_platform.dylib      	0x07b3203b _sigtramp + 43
7   ???                           	0xffffffff 0 + 4294967295
8   com.your-company.AppBugXam    	0x0016a5c0 mono_sigill_signal_handler + 48
9   com.apple.AppSupport          	0x0ad186dc _updateDetachedRecord + 29
10  com.apple.AppSupport          	0x0ad187a5 CPRecordGetProperty + 50
11  com.apple.AppSupport          	0x0ad189b4 CPRecordCopyProperty + 26
12  com.apple.AddressBook         	0x014bb12b ABRecordCopyValueUnfiltered + 133
13  com.apple.AddressBook         	0x014baf9b ABRecordCopyValue + 133

^ the fact that we reached the SIGILL handler looks suspicious
Comment 14 Zoltan Varga 2015-04-21 15:12:09 UTC
It does crash for me in, but the crash looks to happen in native code:

2015-04-21 15:11:07.990 AppBugXam[82025:8240672] critical:   at <unknown> <0xffffffff>
2015-04-21 15:11:07.990 AppBugXam[82025:8240672] critical:   at (wrapper managed-to-native) AddressBook.ABRecord.ABRecordCopyValue (intptr,int) <IL 0x0002e, 0xffffffff>
2015-04-21 15:11:07.990 AppBugXam[82025:8240672] critical:   at AddressBook.ABRecord.CopyValue (int) [0x00000] in /Users/builder/data/lanes/1503/c2c00129/source/maccore/src/AddressBook/ABRecord.cs:190
2015-04-21 15:11:07.990 AppBugXam[82025:8240672] critical:   at AddressBook.ABPerson.GetEmails () [0x00000] in /Users/builder/data/lanes/1503/c2c00129/source/maccore/src/AddressBook/ABPerson.cs:798
2015-04-21 15:11:07.990 AppBugXam[82025:8240672] critical:   at AppBugXam.IPhoneViewController1/<ViewDidLoad>c__async0.MoveNext () [0x000e2] in /Users/vargaz/Projects/28739/AppBugXa
Comment 15 Sebastien Pouliot 2015-04-21 16:11:28 UTC
@Zoltan this is similar to the stack traces I had (most of them, in some cases I did not get any). I found the extra details (the sigill) while looking at the crash report that the simulator/OSX generated.

The fact that it worked before (XI 8.9) and still works on devices makes me think it _could_ be a JIT issue. Maybe it only gets triggered today because of other changes (e.g. MS reference sources) ?
Comment 16 Zoltan Varga 2015-04-21 16:59:36 UTC
The crash happens inside apple code, we just catch the signal. So it could be a mono problem, but it could be something else.
Comment 17 Sebastien Pouliot 2015-04-21 17:03:47 UTC
Yes, something is likely broken before this gets this. Still considering it works with existing/earlier XI versions, and on the same simulator/iOS versions, I think it points toward mono itself.
Comment 18 Sebastien Pouliot 2015-04-24 19:51:02 UTC
*** Bug 29392 has been marked as a duplicate of this bug. ***
Comment 19 Marek Safar 2015-04-27 08:03:28 UTC
This looks like some retain issue. Updating to newer mono could only mean the bug is hit more often because the async method is called with slower/larger delay as we changed the task infrastructure.
Comment 21 Rolf Bjarne Kvinge [MSFT] 2015-05-27 07:48:31 UTC
This is a bug in our dynamic registrar.

Workaround: add '--registrar:static' to the additional mtouch arguments.
Comment 22 Rolf Bjarne Kvinge [MSFT] 2015-05-27 08:17:06 UTC

maccore/master: 70ef4ce4c73cd75db95719c864ebee127b10a067
Comment 23 Rolf Bjarne Kvinge [MSFT] 2015-05-27 08:20:09 UTC
QA: the best repro instructions are in bug 29392.
Comment 25 Ram Chandra 2015-06-01 14:25:05 UTC
I am able to reproduce this issue with following builds:

OS X info: 
Mac OS X 10.10.0
Xamarin.iOS: (Enterprise Edition)
Xcode 6.3 (7569)
Build 6D570

Windows Info:
Windows: 8.1
Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Xamarin   3.11.507.0 (dfac85e)
Xamarin.iOS (7741cc495ab0baf04ff0405d0604bc27f0ecae2e)

Screencast: http://www.screencast.com/t/PbFAAYS0yW
Debug Output: https://gist.github.com/anonymous/b602c9fad7e333bceb57

To verify this issue, I have checked this issue with following builds:

OS X Info: 
Mac OS X 10.10.0
Xamarin.iOS: (Enterprise Edition)
Xcode 6.3 (7569)
Build 6D570

Windows Info:
Windows: 8.1
Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4

I have observed that when I follow the steps mention in Bug 29392, I am not getting any error/exception. Sample application is working fine without any error/exception.

This issue has been fixed. Hence I am closing this issue.
Comment 26 softlion 2015-06-09 03:06:21 UTC
Where can i get 8.11 ?
Comment 27 softlion 2015-06-09 05:54:51 UTC
The workaround is working. Ty.