Closed
Bug 326837
Opened 19 years ago
Closed 18 years ago
invalid assertions on startup [XPCOM objects created/destroyed from static ctor/dtor] (gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_Get ThreadPrivate(gActivityTLS)) == 0)
Categories
(Core :: XPCOM, defect, P3)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: chpe, Assigned: jaas)
References
Details
Attachments
(3 files)
39.34 KB,
application/octet-stream
|
Details | |
2.84 KB,
patch
|
moco
:
review+
|
Details | Diff | Splinter Review |
8.51 KB,
patch
|
benjamin
:
review+
|
Details | Diff | Splinter Review |
With the patch from bug 318622 (checked in as part of patch from bug 325229), gtkmozembed embedders get loads of assertions on startup: ###!!! ASSERTION: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /opt/source/mozilla/trunk/mozilla/xpcom/base/nsTraceRefcntImpl.cpp, line 969 Adding NS_InitLog before using gtk_moz_embed_set_profile_path (and NS_TermLog after the final gtk_moz_embed_pop_startup) makes them go away, but IMHO gtkmozembed embedders shouldn't have to fiddle with that in order not to get those incorrect assertions. They happen: - below gtk_moz_embed_set_profile_path - when I instantiate my nsIDirectoryServiceProvider[2] implementation class, and then use - gtk_moz_embed_set_directory_service_provider - gtk_moz_embed_push_startup For example, they happen below NS_NewNativeLocalFile which is explicitly marked as ok to call before XPCOM startup. And on shutdown they happen too, I haven't gdb'd those though. Traces from the assertions on startup (and one on shutdown, then I quit gdb) @ http://www.gnome.org/~chpe/gdblog .
Comment 1•18 years ago
|
||
I agree that gtk_moz_embed_set_profile_path and friends shouldn't assert, and I can write a patch to fix that. I'm not so certain that instantiating your own nsIDirectoryServiceProvider shouldn't assert; I rather think it should, if you're using the NS_IMPL_ISUPPORTS* macros (which with DEBUG defined will call NS_LogAddRef/Release).
This happens on starting a trunk seamonkey too. The assert is from GRE_Startup calling nsGREDirServiceProvider::AddRef.
Reporter | ||
Comment 3•18 years ago
|
||
(In reply to comment #1) > I'm not so certain that instantiating your own nsIDirectoryServiceProvider > shouldn't assert; I rather think it should, if you're using the > NS_IMPL_ISUPPORTS* macros (which with DEBUG defined will call > NS_LogAddRef/Release). Well, I *need* to instantiate my directory service provider before XPCOM startup, and I don't see why I shouldn't use the provided convenience macros to simplify my code. Also in this instance the warning is *wrong* (or I'm completely misunderstanding it), since my object is in fact new'd, and has no static ctor.
Comment 4•18 years ago
|
||
To the XPCOM debugging code, any addref/release/ctor/dtor outside NS_LogInit/NS_LogTerm is treated as an expected event. It has to be this way, or how else could we know what a static ctor/dtor was? Events that take place outside the logging code will skew the results and report false-positive leaks. If you want to use the NS_Log* functions (in this indirectly through a macro), you're going to need to initialize/term the logging code in a predictable manner.
I think it might be worth excluding some classes from this warning. It can be expected that a lot of users will want to create an nsIDirectoryServiceProvider before starting XPCOM since you need one to call NS_InitXPCOM. It's a pain for users to have to implement their AddRef and Release manually just to avoid the assertion, and we'd rather that people used the macros anyway. What we could do is to check if the object being addrefed QIs to nsIDirectoryServiceProvider, and if it does not assert.
Comment 6•18 years ago
|
||
(In reply to comment #5) > What we could do is to check if the object being addrefed QIs to > nsIDirectoryServiceProvider, and if it does not assert. QI addrefs though...
Hrm.. i spoke too soon. By the time we check ASSERT_ACTIVITY_IS_LEGAL we don't have any pointer we can call QI on (unless we assume that all classes inherit nsISupports as their first baseclass, which i doubt we can rely on). So the other alternative is to provide macros that implements AddRef and Release that doesn't call NS_LOG_ADDREF. Sort of sucks to not log addref/release for the directory providers, but it doesn't look like there's anything else we can do.
Comment 8•18 years ago
|
||
Sure there is, it involves calling NS_LogInit/LogTerm in your main...
Assignee: dougt → benjamin
So we'd pretty much force everyone to call those manually then. Not sure if that is a big deal, but we should be aware of, and document that, that is the proper way to start up XPCOM.
Comment 10•18 years ago
|
||
This is a warning now... I'm pretty sure that I do want to introduce the new behavior here since it is binary-compatible with old release binaries. But we should make XRE_InitEmbedding and the gtkmozembed bits call this automatically.
Updated•18 years ago
|
Priority: -- → P3
Target Milestone: --- → mozilla1.9alpha
Comment 11•18 years ago
|
||
I'd say that NS_New(Native)LocalFile should call it too.
Comment 12•18 years ago
|
||
I get tons of these assertions during startup on Mac :(
Comment 13•18 years ago
|
||
This problem may have been made worse by the recent change to log string buffer AddRef and Release. I think the assertions are somewhat silly. Why can't we just initialize the TLS the first time we get a call and cleanup from the TLS destructor? Any problem with that?
Comment 14•18 years ago
|
||
Hrm? The original intent of the assertions was to catch XPCOM object allocations that happen during static module loads, which is exactly what seems to be happening, unless I'm missing something.
Comment 15•18 years ago
|
||
> Hrm? The original intent of the assertions was to catch XPCOM object
> allocations that happen during static module loads...
OK, I see... so, then perhaps the warning should mention NS_LogInit explicitly to help guide embedders in the right direction.
Comment 16•18 years ago
|
||
Do we understand what's going on on Mac?
Updated•18 years ago
|
Summary: invalid assertions on startup [XPCOM objects created/destroyed from static ctor/dtor] → invalid assertions on startup [XPCOM objects created/destroyed from static ctor/dtor] (gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_Get ThreadPrivate(gActivityTLS)) == 0)
Comment 17•18 years ago
|
||
*** Bug 349285 has been marked as a duplicate of this bug. ***
Comment 18•18 years ago
|
||
So, can we exempt the directory service provider from this warning in some (at worst hackish) way? This bug seems to be especially prevalent on mac, where you get millions of these warnings for every startup.
Comment 19•18 years ago
|
||
We shouldn't be exempting it, we should be adding NS_LogInit/Term pairs around known-good behavior. Do you have stacks for the bogus warnings?
Comment 20•18 years ago
|
||
Here's the stacks + arguments of all such assertions (96 for this startup).
Assignee | ||
Comment 21•18 years ago
|
||
I don't run Firefox in a debugger on anything but Mac OS X, but I can confirm what hwaara says about this being especially bad on Mac OS X - I see an insane number of assertions every time. Since obviously this assertion is pointless when its set off like this, can we at least disable it if nobody is going to fix this any time soon?
Comment 22•18 years ago
|
||
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.9a1) Gecko/20061023 Minefield/3.0a1 Further to comment 18, comment 19 and comment 20: Are you asking to be told the caller responsible for each of these NS_WARNINGS on the Mac?
Comment 23•18 years ago
|
||
(In reply to comment #22) > Further to comment 18, comment 19 and comment 20: Are you asking to be told the > caller responsible for each of these NS_WARNINGS on the Mac? That's what attachment 238412 [details] (comment 20) is.
Comment 24•18 years ago
|
||
Thank you. So to take the first one, do we modify the code at mozilla/xpcom/io/nsLocalFileOSX.cpp:340 ( I think that that is the macro NS_IMPL_THREADSAFE_ISUPPORTS4 ) or mozilla/xpcom/base/nsTraceRefcntImpl.cpp:1025 ( the macro ASSERT_ACTIVITY_IS_LEGAL ) or somewhere else entirely?
Comment 25•18 years ago
|
||
This might help. Josh, please test?
Attachment #245017 -
Flags: review?(joshmoz)
Assignee | ||
Comment 26•18 years ago
|
||
Comment on attachment 245017 [details] [diff] [review] Fix the errors in XRE_main, hopefully, rev. 1 (fixed on trunk) unfortunately it looks like this doesn't really do anything
Attachment #245017 -
Flags: review?(joshmoz) → review-
Assignee | ||
Comment 27•18 years ago
|
||
Thanks for the help bsmedberg! Since we do string operations inside of nsLocalFile::Load on the mac, we get these illegal operation warnings. Other platforms don't do string operations and thus don't have those problems. We really only need to declare certain operations to be illegal during actual library loading.
Attachment #245017 -
Attachment is obsolete: true
Attachment #245515 -
Flags: review?(hwaara)
Assignee | ||
Comment 28•18 years ago
|
||
One thing we might want to change is whether or not we want to put the nsTraceRefcntImpl calls inside or outside of the timeline calls. I put them on the inside in my patch, now I'm leaning towards the outside, and I'll fix that on checkin. NS_TIMELINE_START_TIMER("PR_LoadLibrary"); +#ifdef NS_BUILD_REFCNT_LOGGING + nsTraceRefcntImpl::SetActivityIsLegal(PR_FALSE); +#endif + *_retval = PR_LoadLibrary(mPath.get()); +#ifdef NS_BUILD_REFCNT_LOGGING + nsTraceRefcntImpl::SetActivityIsLegal(PR_TRUE); +#endif + NS_TIMELINE_STOP_TIMER("PR_LoadLibrary"); NS_TIMELINE_MARK_TIMER1("PR_LoadLibrary", mPath.get());
Comment 29•18 years ago
|
||
Comment on attachment 245515 [details] [diff] [review] fix v1.0 bsmedberg is probably a better reviewer for this patch
Attachment #245515 -
Flags: review?(hwaara) → review?(benjamin)
Assignee | ||
Comment 30•18 years ago
|
||
Comment on attachment 245515 [details] [diff] [review] fix v1.0 Yeah, but I wanted him as an sr. I just wanted a sanity check for a first review.
Attachment #245515 -
Flags: review?(benjamin) → review?(mark)
Attachment #245515 -
Flags: review?(mark) → review?(dbaron)
Comment 31•18 years ago
|
||
Comment on attachment 245515 [details] [diff] [review] fix v1.0 >Index: io/nsLocalFileMac.cpp Please remove this file, it is dead code. r=me, no need for separate sr since XPCOM is strongly-owned
Attachment #245515 -
Flags: review?(dbaron) → review+
Assignee | ||
Comment 32•18 years ago
|
||
landed on trunk
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Comment 33•18 years ago
|
||
I'm still seeing this. Did it regress, or was the bug ever actually 100% fixed? AFAICS, it is nsAppRunner code (XRE_main) that is using XPCOM that seems to be triggering all the assertions.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 34•18 years ago
|
||
For example, XRE_GetBinaryPath() asserts a bunch. This line is responsible for the first three assertions: http://tinyurl.com/ycxddh
Comment 35•18 years ago
|
||
> For example, XRE_GetBinaryPath() asserts a bunch. This line is responsible for > the first three assertions: http://tinyurl.com/ycxddh TinyURLs are pretty useless for archiving, especially if you're just linking into LXR anyway... -> <http://landfill.mozilla.org/mxr-test/mozilla/source/toolkit/xre/nsAppRunner.cpp#1076>
Comment 36•18 years ago
|
||
I don't think this needs to be reopened. Bug 362318 covers the remaining reasons for this assertion to fire.
Comment 37•18 years ago
|
||
(In reply to comment #36) > I don't think this needs to be reopened. Bug 362318 covers the remaining > reasons for this assertion to fire. Ok, didn't know about that bug.
Status: REOPENED → RESOLVED
Closed: 18 years ago → 18 years ago
Resolution: --- → FIXED
Comment 38•18 years ago
|
||
Comment on attachment 245017 [details] [diff] [review] Fix the errors in XRE_main, hopefully, rev. 1 (fixed on trunk) Re-requesting review for a change which actually does help fix a class of errors, see bug 362318 for details.
Attachment #245017 -
Flags: review- → review?(sspitzer)
Comment 39•18 years ago
|
||
Comment on attachment 245017 [details] [diff] [review] Fix the errors in XRE_main, hopefully, rev. 1 (fixed on trunk) benjamin, did you want me to review this obsolete patch, or the other one?
Comment 40•18 years ago
|
||
Seth, the obsolete one (it's not really).
Updated•18 years ago
|
Attachment #245017 -
Attachment is obsolete: false
Comment 41•17 years ago
|
||
Comment on attachment 245017 [details] [diff] [review] Fix the errors in XRE_main, hopefully, rev. 1 (fixed on trunk) r=sspitzer, sorry for the delay benjamin!
Attachment #245017 -
Flags: review?(sspitzer) → review+
Updated•17 years ago
|
Attachment #245017 -
Attachment description: Fix the errors in XRE_main, hopefully, rev. 1 → Fix the errors in XRE_main, hopefully, rev. 1 (fixed on trunk)
You need to log in
before you can comment on or make changes to this bug.
Description
•