Closed Bug 77112 Opened 25 years ago Closed 25 years ago

need to define nsCOMPtr_base for debug builds as well

Categories

(Core :: XPCOM, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9

People

(Reporter: shaver, Assigned: shaver)

Details

(Whiteboard: 0.9, baby - just need a=chofmann - ready for checkin)

So right now, if you try to use a non-DEBUG XPCOM component (plugin, whatever) with a DEBUG libxpcom, you get the savagely unpopular: ./regxpcom: error while loading shared libraries: ./regxpcom: undefined symbol: _._13nsCOMPtr_base error. We need to provide a dummy destructor for the DEBUG case, where we don't factor out the destructor for space savings. Perhaps surprisingly, I have a patch.
I think I want this for 0.9, so that people can actually debug with the JVM plugin installed, etc. (What a concept!) There are other symbols that are only exported in the DEBUG case, but I'm less concerned about that case: DEBUG plugins in a non-DEBUG build is a rarer problem, and since _our_ source is available, it should always be possible for a developer to get a DEBUG build to poke at. (Not that we shouldn't fix that, for architectural reasons, but it's not as high-priority. kandrot: do you want to fix those cases?) Index: nsCOMPtr.h =================================================================== RCS file: /cvsroot/mozilla/xpcom/base/nsCOMPtr.h,v retrieving revision 1.81 diff -u -r1.81 nsCOMPtr.h --- nsCOMPtr.h 2001/04/07 17:25:16 1.81 +++ nsCOMPtr.h 2001/04/22 20:32:34 @@ -406,6 +406,8 @@ #ifdef NSCAP_FEATURE_FACTOR_DESTRUCTOR NS_EXPORT ~nsCOMPtr_base(); +#else + NS_EXPORT ~nsCOMPtr_base() { } #endif NS_EXPORT void assign_with_AddRef( nsISupports* );
Status: NEW → ASSIGNED
Keywords: patch, review
Priority: -- → P2
Whiteboard: 0.9, baby
Target Milestone: --- → mozilla0.9
It appears that this patch has allowed me to mix debug and release builds of Komodo on Linux. The different build structure on Win32 means I probably wont test it there.
I have mixed feelings about this patch. (a) it doesn't really fix the problem, it just allows it to compile. The problem is that the code has two different ideas about the shape of an |nsCOMPtr|. Optimized code thinks |nsCOMPtr| inherits from |nsCOMPtr_base|, and thus the base destructor must be called (if it is factored). Debug code thinks |nsCOMPtr| stands alone. This trick allows the code to compile, and even do the right thing, bug only coincidentally. (b) it _seems_ like it should work, and it has a useful impact, so it should probably go in, probably even for 0.9 (c) in the long run, perhaps---as shaver suggests---we should decouple the ``debug |nsCOMPtr| pointer types'' facility from |NS_DEBUG|, and make people ask for it explicitly (but let all the hate mail go to shaver :-) So, with the above noted, sr=scc.
I think that we should make it possible to use debug and optimized code together if possible. How often do people need to debug nsCOMPtr? Never, right scc? :)
The feature that's causing problems here isn't code that lets you debug |nsCOMPtr|, it's code that, when you're looking at an |nsCOMPtr| in the debugger, let's you follow the underlying raw pointer through to its real data, instead of treating it always as an |nsISupports*|. In a world where (for the most part) all objects are accessed only through pointers, suddenly having most of those pointers act like |nsISupports*| in the debugger can really put a damper on things. That's why this feature was such a big ticket item when I first introduced it.
Whiteboard: 0.9, baby → 0.9, baby - have r/sr. a=?
Ok, I'll r=brendan@mozilla.org based on my re-reading of nsCOMPtr.h. Formal considerations (valid ones) notwithstanding, this patch makes things better for developers. /be
Thanks, folks. Just waiting for drivers approval now.
Whiteboard: 0.9, baby - have r/sr. a=? → 0.9, baby - just need a=
a=chofmann
Whiteboard: 0.9, baby - just need a= → 0.9, baby - just need a=chofmann - ready for checkin
I checked in the two-line change, with a two-line comment. /be
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Bug 220291 proposes revising this fix, since it causes leaks whenever it is used.
You need to log in before you can comment on or make changes to this bug.