Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nsIAbDirectory.deleteCards() occasionally throws exception (Tb2)

11 views
Skip to first unread message

Leni

unread,
Jul 6, 2008, 5:55:24 PM7/6/08
to dev-apps-t...@lists.mozilla.org
Hi -

I wonder whether anyone can shed any light on why
nsIAbDirectory.deleteCards() might occasionally throw an
NS_ERROR_INVALID_POINTER exception?

The obvious thing to look at is the cards passed to deleteCards in the
cardArray - but they all seem fine. The odd thing is that a few seconds
later (on the next sync), with seemingly exactly the same inputs,
deleteCards() behaves as expected and deletes the cards.

I can't reliably reproduce this problem, but it's happened often enough
for me to be sure that there something happening that I don't
understand. Any suggestions around strategies for getting to the bottom
of it would be welcome.

Leni

[JavaScript Error: "uncaught exception: [Exception... "Component
returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER)
[nsIAbDirectory.deleteCards]" nsresult: "0x80004003
(NS_ERROR_INVALID_POINTER)" location: "JS frame :: chrome://zindus/
content/addressbook.js :: anonymous :: line 342" data: no]"]

[JavaScript Error: "[Exception... "'Component does not have requested
interface' when calling method: [nsIInterfaceRequestor::getInterface]"
nsresult: "0x80004002 (NS_NOINTERFACE)" location: "JS frame ::
file:///usr/lib64/thunderbird/components/
nsMailDefaultHandler.js :: openURI :: line 83" data: no]" {file:
"file:///usr/lib64/thunderbird/components/nsMailDefaultHandler.js" line:
83}]

[JavaScript Error: "[Exception... "'JavaScript component does not have a
method named: "NotifyComposeBodyReady"' when calling method:
[nsIMsgComposeStateListener::NotifyComposeBodyReady]" nsresult:
"0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTI
ON_NAMED)" location: "JS frame ::
chrome://messenger/content/messengercompose/MsgComposeCommands.js ::
InitEditor :: line 3586" data: no]"
{file:
"chrome://messenger/content/messengercompose/MsgComposeCommands.js"
line: 3586}]

Joshua Cranmer

unread,
Jul 6, 2008, 6:27:24 PM7/6/08
to
Leni wrote:
> Hi -
>
> I wonder whether anyone can shed any light on why
> nsIAbDirectory.deleteCards() might occasionally throw an
> NS_ERROR_INVALID_POINTER exception?

NS_ERROR_INVALID_POINTER means that someone is passing in a null value
to an outparam. This is either a bug on our end or a misuse of interface
on the consumers' end; I haven't looked in enough detail to find where
the problem is.

> I can't reliably reproduce this problem, but it's happened often enough
> for me to be sure that there something happening that I don't
> understand. Any suggestions around strategies for getting to the bottom
> of it would be welcome.

If you had a debug build, hopefully some of the errors will be printed
out in information similar to the following:

WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with nsresult 0x80004003 at
<file>, <line>

Leni

unread,
Jul 6, 2008, 6:55:22 PM7/6/08
to Joshua Cranmer, dev-apps-t...@lists.mozilla.org
Joshua Cranmer wrote:

> Leni wrote:
>> I wonder whether anyone can shed any light on why
>> nsIAbDirectory.deleteCards() might occasionally throw an
>> NS_ERROR_INVALID_POINTER exception?
>
> NS_ERROR_INVALID_POINTER means that someone is passing in a null value
> to an outparam.

Mm, deleteCards only has an "in" param (from nsIAbDirectory.idl):
void deleteCards(in nsISupportsArray cards);

> If you had a debug build, hopefully some of the errors will be printed
> out in information similar to the following:
>
> WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with nsresult 0x80004003 at
> <file>, <line>

Good suggestion, thanks!

Leni.

Dan Mosedale

unread,
Jul 7, 2008, 8:41:28 PM7/7/08
to
Leni wrote:
> Joshua Cranmer wrote:
>> Leni wrote:
>>> I wonder whether anyone can shed any light on why
>>> nsIAbDirectory.deleteCards() might occasionally throw an
>>> NS_ERROR_INVALID_POINTER exception?
>>
>> NS_ERROR_INVALID_POINTER means that someone is passing in a null value
>> to an outparam.
>
> Mm, deleteCards only has an "in" param (from nsIAbDirectory.idl):
> void deleteCards(in nsISupportsArray cards);
>

That error is often used for "in" params as well.

Dan

Leni

unread,
Jul 9, 2008, 10:19:49 PM7/9/08
to dev-apps-t...@lists.mozilla.org
Just mulling over a methodology for getting to the bottom of this.

Are there any tests that can be run on the "in" param card array to
validate it? The idea being that if the "in" param is definitely valid
and an exception gets thrown, the finger is pointed at
nsIAbDirectory.deleteCards().

Currently, each abCard in the array is printed out (calling
abCard.getCardValue()) before deletion. Visually, the array and it's
abCards all look fine. If that's the best that can be done, that's
cool, just asking in case there's something I'm missing.

Leni.

> _______________________________________________
> dev-apps-thunderbird mailing list
> dev-apps-t...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-apps-thunderbird

Leni

unread,
Jul 16, 2008, 9:53:58 PM7/16/08
to Joshua Cranmer, dev-apps-t...@lists.mozilla.org
This question is about adding a card. It's linked to the deleteCards()
issue because the behaviour varies depending on whether the addressbook
is open or not.

Running thunderbird 2.0.0.14 in debug mode, I notice these errors on the
console when I call the addCard() function below. You can test this by
copy/pasting the addCard() function into the Error Console.

WARNING: NS_ENSURE_TRUE(mListeners) failed, file
c:/cygwin/home/L/wrk/mozilla/mailnews/addrbook/src/nsAddrBookSession.cpp,
line 94
WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file
c:/cygwin/home/L/wrk/mozilla/mailnews/addrbook/src/nsAbMDBDirectory.cpp,
line 220
WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file
c:/cygwin/home/L/wrk/mozilla/mailnews/addrbook/src/nsAbMDBDirectory.cpp,
line 898
WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file
c:/cygwin/home/L/wrk/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp,
line 299

But with the Addressbook open, the card gets added without warning messages.

Should I file a bug on this?

Also, if this isn't the right forum for raising such questions, I'm
happy to be redirected elsewhere!

Leni.


function addCard()
{
var uri = "moz-abmdbdirectory://abook.mab";
var dir =
Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService).GetResource(uri).QueryInterface(Components.interfaces.nsIAbDirectory);
var abCard =
Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance().QueryInterface(Components.interfaces.nsIAbCard);
abCard = dir.addCard(abCard);

abCard.setCardValue("PrimaryEmail", "111-...@example.com");
abCard.setCardValue("DisplayName", "111 test");

var mdbCard =
abCard.QueryInterface(Components.interfaces.nsIAbMDBCard);
mdbCard.editCardToDatabase(uri);
}
addCard();

Leni

unread,
Jul 16, 2008, 8:40:55 PM7/16/08
to Joshua Cranmer, dev-apps-t...@lists.mozilla.org
Joshua Cranmer wrote:
> Leni wrote:
>> I wonder whether anyone can shed any light on why
>> nsIAbDirectory.deleteCards() might occasionally throw an
>> NS_ERROR_INVALID_POINTER exception?
>
> If you had a debug build, hopefully some of the errors will be printed
> out in information similar to the following:

With enough beating on it I can sometimes reproduce this error.

Here's what's in the console under a debug build of 2.0.0.14:

WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file
/home/L/wrk/mozilla/mailnews/addrbook/src/nsAbMDBDirectory.cpp, line 559

This is:
rv = RemoveCardFromAddressList(card);
NS_ENSURE_SUCCESS(rv,rv);

The NS_ERROR_NULL_POINTER is returned by RemoveCardFromAddressList() here:
if (!m_AddressList)
{
rv = mDatabase->GetMailingListsFromDB(this);
NS_ENSURE_SUCCESS(rv, rv);
// Ensure that the previous call did set the address list pointer
if (!m_AddressList)
return NS_ERROR_NULL_POINTER;
}

What's interesting is that when the addressbook is open at the same time
as the test is run, deleteCards() always works fine (m_AddressList is
true on entering the function). "Open the addressbook to make this
problem go away" is a damned odd thing to suggest to users by way of a
workaround, but it does seem to do the trick.

Just sharing this in case it prompts any suggestions - eg things to try
or whether there's enough data here to file a bug.

Leni.

0 new messages