Created attachment 377071 [details] JS to reproduce the exceptions When working on my extension I kept breaking directories from syncing contacts without e-mail addresses to mailing lists. It is the leading subject in e-mail and comments about my extension because it can be caused by dragging and dropping contacts into a mailing list as well. It now adds a fake e-mail address to contacts added to mailing lists by overriding the abDirTreeObserver.onDrop and CheckAndSetCardValues methods (among others), but can still miss some cases. After the contact is added to this list, calling hasMoreElements on an nsISimpleEnumerator of the list's childCards fails with NS_ERROR_FAILURE, and calls to nsIAbDirectory.addCard fail with NS_ERROR_INVALID_POINTER. See the attachment for a line to evaluate in the Error Console. It only works in Thunderbird 3.0b1pre and above, but I can attach one for 2 as well. I can reproduce the error in Thunderbird 184.108.40.206pre, 3.0b3pre, and 3.1a1pre. The main problem lies in nsAddrDatabase::AddListCardColumnsToRow on line 1359 . It checks if the contact has an e-mail address and just returns NS_OK if not. I know it defeats the original purpose of a mailing list, but allowing contacts without e-mail addresses would be nice for extensions at least. This, however, would require a more complicated patch since duplicate e-mail addresses won't work in mailing lists. Otherwise, returning an error would allow extensions to catch it and add a fake e-mail address.  http://mxr.mozilla.org/comm-central/source/mailnews/addrbook/src/nsAddrDatabase.cpp#1359
Created attachment 377076 [details] [diff] [review] A patch that allows one contact w/o an e-mail address per list This is just a sample patch (not for review) that allows contacts without an e-mail address to be added to a mailing list. Due to the unique e-mail restriction this still won't allow multiple contacts without e-mail addresses in the same list.
I have managed to get the NS_ERROR_INVALID_POINTER when exporting, deleting, then importing an address book with mailing lists without restarting Thunderbird. The import was unable to add the contact to the list, but I didn't see anything in a debug build until I tried to manually add the contact.