tigerdog ([info]tigerdog) wrote in [info]bezilla,
@ 2007-04-16 21:46:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Getting there - trunk broken in a new and exciting place
Armed with my newly-functioning cairo package, I have successfully updated my CVS to current trunk and reapplied an uncommitted patch to take care of a regression from bug 338078, I've now discovered new bustage, maybe a case of 2.95.3 versus newer gcc behavior. If anyone can take a look and offer a suggestion, I'd appreciate it. I've created bug 377730 to report the bug. Here are the details:


c++ -o xpcwrappedjs.o -c -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1 -DMOZILLA_INTERNAL_API -DOSTYPE=\"BeOS6.2\" -DOSARCH=BeOS -DBUILD_ID=0000000000 -DJSFILE -DJS_THREADSAFE -DEXPORT_XPC_API -I/Padauk/home/develop/mozilla/js/src/xpconnect/src/../loader -I../../../../dist/include/xpcom -I../../../../dist/include/string -I../../../../dist/include/js -I../../../../dist/include/caps -I../../../../dist/include/necko -I../../../../dist/include/dom -I../../../../dist/include -I../../../../dist/include/xpconnect -I../../../../dist/include/nspr -DMOZ_PNG_READ -DMOZ_PNG_WRITE -I../../../../dist/sdk/include -frtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-multichar -Wno-long-long -pedantic -pipe -DNDEBUG -DTRIMMED -O2 -DMOZILLA_CLIENT -include ../../../../mozilla-config.h -Wp,-MD,.deps/xpcwrappedjs.pp /Padauk/home/develop/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp
/Padauk/home/develop/mozilla/js/src/xpconnect/src/xpcprivate.h: In method `nsresult nsXPCWrappedJS::cycleCollection::Traverse(nsISupports *, nsCycleCollectionTraversalCallback &)':
/Padauk/home/develop/mozilla/js/src/xpconnect/src/xpcprivate.h:2262: `class nsAutoRefCnt nsXPCWrappedJS::mRefCnt' is protected
/Padauk/home/develop/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp:83: within this context
make[5]: *** [xpcwrappedjs.o] Error 1
make[5]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo/js/src/xpconnect/src'
make[4]: *** [libs] Error 2
make[4]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo/js/src/xpconnect'
make[3]: *** [libs_tier_gecko] Error 2
make[3]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo'
make[2]: *** [tier_gecko] Error 2
make[2]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo'
make[1]: *** [default] Error 2
make[1]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo'
make: *** [build] Error 2
$



(Post a new comment)


[info]tqh
2007-04-17 06:37 am UTC (link)
I've submitted a couple of bugs just like that, they should have patches that gives a hint. Might even be for that one.

(Reply to this) (Thread)

trying to understand "friend class"
[info]tigerdog
2007-04-17 02:36 pm UTC (link)
I'm trying to get my mind around what's happening here.
xpcprivate.h:2263: `class nsAutoRefCnt nsXPCWrappedJS::mRefCnt' is protected
xpcwrappedjs.cpp:83: within this context

Does this mean nsXPCWrappedJS can't be accessed in xpcwrappedjs.cpp because it's protected? So nsXPCWrappedJS needs to be made a friend class of what? nsAutoRefCnt?

I appreciate the challenge here, and I'm trying to figure it out but I'm really struggling to understand what's happening.

(Reply to this) (Parent)(Thread)

Re: trying to understand "friend class"
[info]tqh
2007-04-18 09:15 am UTC (link)
It's a bit messy.

As I understand it the class cycleCollection has tried to get to nsXPCWrappedJS::mRefCnt.
cycleCollection is defined as NS_CYCLE_COLLECTION_INNERCLASS here http://lxr.mozilla.org/seamonkey/source/xpcom/base/nsCycleCollectionParticipant.h#121

What would be needed is to tell nsXPCWrappedJS that cycleCollection can touch mRefCnt.

This would probably mean adding friend to the line 'class NS_CYCLE_COLLECTION_INNERCLASS'
here:
http://lxr.mozilla.org/seamonkey/source/xpcom/base/nsCycleCollectionParticipant.h#246

which thru some detective work is defined here: http://lxr.mozilla.org/seamonkey/source/js/src/xpconnect/src/xpcprivate.h#2267

Sometimes I wonder if they progam in the preprocessor or in C++. There are design patterns nowadays..

(Reply to this) (Parent)(Thread)

Re: trying to understand "friend class"
[info]tigerdog
2007-04-19 05:39 pm UTC (link)
I'm glad you think it's messy, too, and it not just me. As usual, I'm having trouble figuring out exactly how this should look. I'll keep beating on it.

(Reply to this) (Parent)(Thread)

Re: trying to understand "friend class"
[info]tqh
2007-04-19 08:44 pm UTC (link)
Did you try my suggestion?

"adding friend to the line 'class NS_CYCLE_COLLECTION_INNERCLASS'"

friend class NS_CYCLE_COLLECTION_INNERCLASS

at nsCycleCollectionParticipant.h#246

(Reply to this) (Parent)(Thread)

Re: trying to understand "friend class"
[info]tqh
2007-04-19 08:45 pm UTC (link)
You probably need to rebuild all

(Reply to this) (Parent)

Re: trying to understand "friend class"
[info]tigerdog
2007-04-19 09:06 pm UTC (link)
I tried it with make clean and make in xpcom and js/src/xpconnect/src, but not with a complete clean build; it made lots of errors. I'm trying a complete build now.

(Reply to this) (Parent)

Re: trying to understand "friend class"
[info]tigerdog
2007-04-19 09:19 pm UTC (link)
Looks like the clean build took care of this bug. I'm on to the next one.

(Reply to this) (Parent)

Next bug - same story
[info]tigerdog
2007-04-19 09:25 pm UTC (link)
Looks like the next bug is caused by something similar:

nsInMemoryDataSource.cpp
c++ -o nsInMemoryDataSource.o -c -DMOZILLA_INTERNAL_API -DOSTYPE=\"BeOS6.2\" -DOSARCH=BeOS -DBUILD_ID=0000000000 -I../../../dist/include/xpcom -I../../../dist/include/string -I../../../dist/include/rdfutil -I../../../dist/include/necko -I../../../dist/include/content -I../../../dist/include/htmlparser -I../../../dist/include/xpconnect -I../../../dist/include/unicharutil -I../../../dist/include -I../../../dist/include/rdf -I../../../dist/include/nspr -DMOZ_PNG_READ -DMOZ_PNG_WRITE -I../../../dist/sdk/include -frtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-multichar -Wno-long-long -pedantic -pipe -DNDEBUG -DTRIMMED -O2 -DMOZILLA_CLIENT -include ../../../mozilla-config.h -Wp,-MD,.deps/nsInMemoryDataSource.pp /Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp: In function `static class InMemoryDataSource * InMemoryDataSource::cycleCollection::Downcast(nsISupports *)':
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:351: `class InMemoryDataSource::Internal InMemoryDataSource::fAggregated' is private
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:352: within this context
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:352: warning: control reaches end of non-void function `InMemoryDataSource::cycleCollection::Downcast(nsISupports *)'
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp: In method `nsresult InMemoryDataSource::cycleCollection::Unlink(nsISupports *)':
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:312: `class nsCOMArray InMemoryDataSource::mObservers' is protected
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:980: within this context
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp: In method `nsresult InMemoryDataSource::cycleCollection::Traverse(nsISupports *, nsCycleCollectionTraversalCallback &)':
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:351: `class nsCycleCollectingAutoRefCnt InMemoryDataSource::mRefCnt' is protected
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:982: within this context
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:312: `class nsCOMArray InMemoryDataSource::mObservers' is protected
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:983: within this context
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:312: `class nsCOMArray InMemoryDataSource::mObservers' is protected
/Padauk/home/develop/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:983: within this context
make[6]: *** [nsInMemoryDataSource.o] Error 1
make[6]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo/rdf/base/src'
make[5]: *** [libs] Error 2
make[5]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo/rdf/base'
make[4]: *** [libs] Error 2
make[4]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo/rdf'
make[3]: *** [libs_tier_gecko] Error 2
make[3]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo'
make[2]: *** [tier_gecko] Error 2
make[2]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo'
make[1]: *** [default] Error 2
make[1]: Leaving directory `/Padauk/home/develop/mozilla/opt-Zeta-cairo'
make: *** [build] Error 2
$
$


Seems there's a fundamental incompatibility between 2.95.3 and later compilers around how protected variables are handled, as you've pointed out.

(Reply to this) (Parent)(Thread)

Re: Next bug - same story
[info]tqh
2007-04-20 06:40 am UTC (link)
It's not the variables themselves. It's with internal classes. A class can have an internal class ie it is declared inside the first class.

In newer gcc the internal class is allowed to touch the variables of the first class, while gcc2.95 is more strict and won't allow it until you inform the compiler that the internal class is a friend.

(Reply to this) (Parent)(Thread)

Re: Next bug - same story
[info]tqh
2007-04-20 08:50 am UTC (link)
Make new friends:

http://lxr.mozilla.org/seamonkey/source/xpcom/base/nsAgg.h#102

This line:
class NS_CYCLE_COLLECTION_INNERCLASS
should be
friend class NS_CYCLE_COLLECTION_INNERCLASS

It can be done prettier later on, but that should probably get you further. I'm not sure if there is one or two problems in the output you posted, but go on and try it. Full build again...

(Reply to this) (Parent)(Thread)

Re: Next bug - same story
[info]tigerdog
2007-04-20 04:02 pm UTC (link)
Yes, that was it. Thanks tqh!

Now we're into the real fun stuff - trying to build Thebes/Cairo. I may be crying out to biesi for help on the next bugs.

(Reply to this) (Parent)

Trying to implement as David Barron suggests
[info]tigerdog
2007-04-21 12:17 am UTC (link)
In a comment in the bug, David Barron suggested we work around this problem using code like this:

class Inner;
friend class Inner;
class Inner {
// definition
};

I tried replacing this

#define NS_DECL_AGGREGATED_CYCLE_COLLECTION_CLASS(_class) \
class NS_CYCLE_COLLECTION_INNERCLASS \

: public nsCycleCollectionParticipant \
{ \
public: \

With this:

#define NS_DECL_AGGREGATED_CYCLE_COLLECTION_CLASS(_class) \
class NS_CYCLE_COLLECTION_INNERCLASS; \
friend class NS_CYCLE_COLLECTION_INNERCLASS; \
class NS_CYCLE_COLLECTION_INNERCLASS \

: public nsCycleCollectionParticipant \
{ \
public: \

but the code wouldn't build. I'll keep banging on it - I suspect I'm putting friend class in the wrong place again...

(Reply to this) (Parent)

Trying to implement as David Barron suggests
[info]tigerdog
2007-04-21 12:19 am UTC (link)
In a comment in the bug, David Barron suggested we work around this problem using code like this:

class Inner;
friend class Inner;
class Inner {
// definition
};

I tried replacing this

#define NS_DECL_AGGREGATED_CYCLE_COLLECTION_CLASS(_class)
class NS_CYCLE_COLLECTION_INNERCLASS

: public nsCycleCollectionParticipant
{

With this:

#define NS_DECL_AGGREGATED_CYCLE_COLLECTION_CLASS(_class)
class NS_CYCLE_COLLECTION_INNERCLASS;
friend class NS_CYCLE_COLLECTION_INNERCLASS;
class NS_CYCLE_COLLECTION_INNERCLASS

: public nsCycleCollectionParticipant
{

but the code wouldn't build. I'll keep banging on it - I suspect I'm putting friend class in the wrong place again...

(Reply to this) (Parent)(Thread)

Re: Trying to implement as David Barron suggests
[info]tqh
2007-04-22 08:56 am UTC (link)
There should only be
of
class NS_CYCLE_COLLECTION_INNERCLASS;
and
friend class NS_CYCLE_COLLECTION_INNERCLASS;

It states that there is a class NS_CYCLE_COLLECTION_INNERCLASS, or that there is a class and that it is a friend.


Also I suspect that all this should be part of the #define statement, so all the lines except the last one needs to end with two backslashes.

(Reply to this) (Parent)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…