Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Comparing XPCOM Objects broken
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Philipp Kewisch  
View profile  
 More options May 19 2011, 4:07 am
Newsgroups: mozilla.dev.platform
From: Philipp Kewisch <kewi...@gmail.com>
Date: Thu, 19 May 2011 01:07:45 -0700 (PDT)
Local: Thurs, May 19 2011 4:07 am
Subject: Comparing XPCOM Objects broken
Hello Folks,

I haven't found a regression range for this yet, but I just noticed
that the method we've been using to compare wrapped xpcom objects
seems to be broken. Maybe someone can help out and tell me how to
better do this.

The background is that we have a few places where we need to compare
two objects for equality, in Javascript.The naive approach would be to
use a == compare, but this doesn't work since an object can be wrapped
in multiple ways (either not wrapped, or using different interfaces,
or even using the same interfaces but wrapped differently), which
causes the compare to fail.

What has been working before, but has always been giving us a strange
feeling is using supports-interface-pointer:
function compareObject(a, b, iid) {
  var sip1 = Components.classes["@mozilla.org/supports-interface-
pointer;1"]
        .createInstance(Components.interfaces.nsISupportsInterfacePointer);

  var sip2 = Components.classes["@mozilla.org/supports-interface-
pointer;1"]
        .createInstance(Components.interfaces.nsISupportsInterfacePointer);

  sip1.data = a;
  sip2.data = b;
  sip1.dataIID = iid;
  sip2.dataIID = iid;

  return sip1.data == sip2.data;

}

Using comm-central, this no longer works. Now the big question is, how
do we solve this using todays code? Is there some API we have missed?
Working around this by using a member of the object for comparison
would mean a substantial amount of work so I would like to avoid that.

Thanks in advance,
Philipp


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Boris Zbarsky  
View profile  
 More options May 19 2011, 8:54 am
Newsgroups: mozilla.dev.platform
From: Boris Zbarsky <bzbar...@mit.edu>
Date: Thu, 19 May 2011 08:54:58 -0400
Local: Thurs, May 19 2011 8:54 am
Subject: Re: Comparing XPCOM Objects broken
On 5/19/11 4:07 AM, Philipp Kewisch wrote:

> Using comm-central, this no longer works.

In what cases?  What are the objects in question when this no longer works?

-Boris


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ehsan Akhgari  
View profile  
 More options May 19 2011, 1:46 pm
Newsgroups: mozilla.dev.platform
From: Ehsan Akhgari <ehsan.akhg...@gmail.com>
Date: Thu, 19 May 2011 13:46:27 -0400
Local: Thurs, May 19 2011 1:46 pm
Subject: Re: Comparing XPCOM Objects broken
I was under the impression that comparing XPCOM objects should consist
of QIing them to nsISupports and compare the pointer values.

Ehsan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Boris Zbarsky  
View profile  
 More options May 19 2011, 1:48 pm
Newsgroups: mozilla.dev.platform
From: Boris Zbarsky <bzbar...@mit.edu>
Date: Thu, 19 May 2011 13:48:35 -0400
Local: Thurs, May 19 2011 1:48 pm
Subject: Re: Comparing XPCOM Objects broken
On 5/19/11 1:46 PM, Ehsan Akhgari wrote:

> I was under the impression that comparing XPCOM objects should consist
> of QIing them to nsISupports and compare the pointer values.

That's effectively what the posted code using
nsISupportsInterfacePointer is doing.

-Boris


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philipp Kewisch  
View profile  
 More options May 20 2011, 5:57 am
Newsgroups: mozilla.dev.platform
From: Philipp Kewisch <kewi...@gmail.com>
Date: Fri, 20 May 2011 02:57:31 -0700 (PDT)
Local: Fri, May 20 2011 5:57 am
Subject: Re: Comparing XPCOM Objects broken
On May 19, 2:54 pm, Boris Zbarsky <bzbar...@mit.edu> wrote:

> In what cases?  What are the objects in question when this no longer works?

I haven't tested it for other objects, but specifically for these it
doesn't work. The control flow is that I have an observer
(calAlarmMonitor) that registers with an observer service
(calAlarmService). Adding the observer works perfectly, but removing
the observer again doesn't remove it from the interface bag. The
remove function compares all array objects with the passed object to
remove the right one.

The visible effect is that a shutdown/startup of the alarm service
duplicates the alarms, since then two observers are registered. This
happens when the computer goes into sleep state and wakes up again.

This is the observer used:
http://mxr.mozilla.org/comm-central/source/calendar/base/src/calAlarm...

It is added to the alarm service here:
http://mxr.mozilla.org/comm-central/source/calendar/base/src/calAlarm...

Which delegates to the listener/interface bag:
http://mxr.mozilla.org/comm-central/source/calendar/base/src/calUtils...
Using the Interface calIAlarmServiceObserver:
http://mxr.mozilla.org/comm-central/source/calendar/base/public/calIA...

The compareObjects function is similar to the one posted above.

Sorry for the high number of involved files, I can try to create a
reduced testcase if needed. Let me know if I can provide additional
info.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Neil  
View profile  
 More options May 20 2011, 6:26 am
Newsgroups: mozilla.dev.platform
From: Neil <n...@parkwaycc.co.uk>
Date: Fri, 20 May 2011 11:26:22 +0100
Local: Fri, May 20 2011 6:26 am
Subject: Re: Comparing XPCOM Objects broken

Weird. The alarm service is an XPCOM object, so it should be getting
wrappers for any passed-in objects anyway. And you definitely pass in
the same object twice, so you should get the same wrapper twice, or
failing that, they should both wrap the same wrapped JS object, and you
should therefore be able compare them directly with ==.

--
Warning: May contain traces of nuts.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philipp Kewisch  
View profile  
 More options May 20 2011, 6:42 am
Newsgroups: mozilla.dev.platform
From: Philipp Kewisch <kewi...@gmail.com>
Date: Fri, 20 May 2011 03:42:20 -0700 (PDT)
Local: Fri, May 20 2011 6:42 am
Subject: Re: Comparing XPCOM Objects broken
On May 20, 12:26 pm, Neil <n...@parkwaycc.co.uk> wrote:
> failing that, they should both wrap the same wrapped JS object, and you
> should therefore be able compare them directly with ==.

Direct compare fails too. I also tried just QIing to nsISupports and
then comparing, but to no avail.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Justin Lebar  
View profile  
 More options May 20 2011, 8:35 am
Newsgroups: mozilla.dev.platform
From: Justin Lebar <justin.le...@gmail.com>
Date: Fri, 20 May 2011 05:35:03 -0700 (PDT)
Local: Fri, May 20 2011 8:35 am
Subject: Re: Comparing XPCOM Objects broken
It would be really helpful if you could bisect this.  I touched this code in 9ad5c138c2d5, and that might somehow be causing your problem, although I suspect that if it were, lots of other things would be broken.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philipp Kewisch  
View profile  
 More options May 24 2011, 1:31 pm
Newsgroups: mozilla.dev.platform
From: Philipp Kewisch <kewi...@gmail.com>
Date: Tue, 24 May 2011 10:31:48 -0700 (PDT)
Local: Tues, May 24 2011 1:31 pm
Subject: Re: Comparing XPCOM Objects broken
On May 20, 2:35 pm, Justin Lebar <justin.le...@gmail.com> wrote:

> It would be really helpful if you could bisect this.  I touched this code in 9ad5c138c2d5, and that might somehow be causing your problem, although I suspect that if it were, lots of other things would be broken.

I'm having a bit trouble compiling older versions of comm-central with
mozilla-central, but when I started I had a mozilla-central revision
before 9ad5c138c2d5. It neither works on that version I had before,
nor on the latest mozilla-central so 9ad5c138c2d5 is neither the
culprit nor the savior.

I'll let you know when I found out when or if it used to work.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philipp Kewisch  
View profile  
 More options Jun 5 2011, 11:18 am
Newsgroups: mozilla.dev.platform
From: Philipp Kewisch <kewi...@gmail.com>
Date: Sun, 5 Jun 2011 08:18:31 -0700 (PDT)
Local: Sun, Jun 5 2011 11:18 am
Subject: Re: Comparing XPCOM Objects broken
On May 24, 7:31 pm, Philipp Kewisch <kewi...@gmail.com> wrote:

> On May 20, 2:35 pm, Justin Lebar <justin.le...@gmail.com> wrote:

> > It would be really helpful if you could bisect this.  I touched this code in 9ad5c138c2d5, and that might somehow be causing your problem, although I suspect that if it were, lots of other things would be broken.

> I'm having a bit trouble compiling older versions of comm-central with
> mozilla-central, but when I started I had a mozilla-central revision
> before 9ad5c138c2d5. It neither works on that version I had before,
> nor on the latest mozilla-central so 9ad5c138c2d5 is neither the
> culprit nor the savior.

> I'll let you know when I found out when or if it used to work.

Back again. I'm having trouble finding the exact revision since my
special case requires a combination of working comm-central/mozilla-
central, but at least I'm a bit closer. This seems to have happened
somewhere during the component manifest merges, which makes it
especially troubling. Next I fear I need to make a reduced testcase
that depends only on mozilla-central.

Known Good: 2010-06-05

Known Bad: 2010-08-20

I'll let you know when I have found a closer regression range, that
includes actual revision numbers. Maybe someone already has an idea
what could be the cause with the above info.

Philipp


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philipp Kewisch  
View profile  
 More options Jun 8 2011, 3:07 am
Newsgroups: mozilla.dev.platform
From: Philipp Kewisch <kewi...@gmail.com>
Date: Wed, 8 Jun 2011 00:07:28 -0700 (PDT)
Local: Wed, Jun 8 2011 3:07 am
Subject: Re: Comparing XPCOM Objects broken
I couldn't get too close via bisect, due to build errors in mozilla-
central. Also those results don't really match with what I found out
later via testing nightlies. Anyway, here goes:

Last working revision:
changeset:   46996:fe832b373724
user:        Benjamin Smedberg <benja...@smedbergs.us>
date:        Thu Jun 10 12:51:43 2010 -0400
summary:     Bug 570488 part B - fix and test loading XPT files from
JARs, needed for omnijar, r=mwu

First known bad revision:
changeset:   47029:014f02585f6d
user:        Benjamin Smedberg <benja...@smedbergs.us>
date:        Tue Jun 22 20:21:34 2010 -0400
summary:     Rename NSGetModule to NSModule in various build scripts
for bug 568691.

Next, I tried nightly builds. As mentioned, the dates don't really fit
together with the above revisions, but maybe I tried the wrong
nightlies? I used the nightlies from
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2010/07/2010-xx...

Last working Nightly:
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:2.0b2pre) Gecko/20100701
Minefield/4.0b2pre

First bad Nightly:
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:2.0b2pre) Gecko/20100702
Minefield/4.0b2pre

Anything else to note before I file a bug?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Justin Lebar  
View profile  
 More options Jun 8 2011, 8:44 am
Newsgroups: mozilla.dev.platform
From: Justin Lebar <justin.le...@gmail.com>
Date: Wed, 8 Jun 2011 05:44:55 -0700 (PDT)
Local: Wed, Jun 8 2011 8:44 am
Subject: Re: Comparing XPCOM Objects broken

> Anything else to note before I file a bug?

I think you should go for it.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Boris Zbarsky  
View profile  
 More options Jun 8 2011, 1:28 pm
Newsgroups: mozilla.dev.platform
From: Boris Zbarsky <bzbar...@mit.edu>
Date: Wed, 08 Jun 2011 10:28:42 -0700
Local: Wed, Jun 8 2011 1:28 pm
Subject: Re: Comparing XPCOM Objects broken
On 6/8/11 12:07 AM, Philipp Kewisch wrote:

> Last working Nightly:
> Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:2.0b2pre) Gecko/20100701
> Minefield/4.0b2pre

> First bad Nightly:
> Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:2.0b2pre) Gecko/20100702
> Minefield/4.0b2pre

> Anything else to note before I file a bug?

Nope.  Just make sure to include the about:buildconfig strings from
those nightlies in the bug report.

-Boris


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philipp Kewisch  
View profile  
 More options Jun 8 2011, 4:42 pm
Newsgroups: mozilla.dev.platform
From: Philipp Kewisch <kewi...@gmail.com>
Date: Wed, 8 Jun 2011 13:42:53 -0700 (PDT)
Local: Wed, Jun 8 2011 4:42 pm
Subject: Re: Comparing XPCOM Objects broken
 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »