[Mono-bugs] [Bug 707114] crash when collecting all persons from ABAddressBook

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Aug 2 17:04:04 EDT 2011



--- Comment #11 from Jonathan Pryor <jonpryor at vt.edu> 2011-08-02 21:04:03 UTC ---
Based on the code and description, it does appear to be a "premature"
collection, as ABPerson doesn't contain a reference to ABAddressBook, so the GC
won't know that the ABPerson reference depends upon the ABAddressBook instance.

A good way to test to see if this is the case would be to change AddressBook.cs
CollectContacts() to do:

    var addressBook = new ABAddressBook();
    var person = addressBook.GetPeople()[0];  // better have at least one
    _allContacts.Add (new Contact { FirstName = person.FirstName });

As for how to fix this, I'm not sure. We could add an ABRecord.AddressBook
property to keep the ABAddressBook alive, but we'd need to take care to set
this property within ABAddressBook.GetPeople() and any other method that
creates a new ABRecord subclass. This would also be adding a member that
doesn't exist in the underlying API; I'm not sure if this would be desirable.

On a related note, the ABAddressBookCreate() docs explicitly state:


    "Important: You must ensure that an instance of ABAddressBookRef is used by
only one thread."

If the GC is run on a different thread, this could be bad. :-)

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list