Closed
Bug 45068
Opened 25 years ago
Closed 14 years ago
NS_ShutdownXPCOM followed by NS_InitXPCOM leaks and crashes
Categories
(Core :: XPCOM, enhancement, P4)
Core
XPCOM
Tracking
()
RESOLVED
WONTFIX
Future
People
(Reporter: jonsmirl, Unassigned)
References
Details
(4 keywords)
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 95)
BuildID: CVS
NS_ShutdownXPCOM followed by NS_InitXPCOM. Right now I can shutdown ok but when
I reinit XPCOM I GPF on NS_ADDREF(thread) in GetIThread(). It looks like self-
>privateData in PR_GetThreadPrivate is pointing to memory that was freed in
XPCOM shutdown.
Reproducible: Always
Steps to Reproduce:
NS_ShutdownXPCOM followed by NS_InitXPCOM
Here's the fix, a dangling point is left in the thread local storage after the
thread object has been deleted.
Change the shutdown function in xpcom/threads/nsThread.cpp...
void
nsThread::Shutdown()
{
if (gMainThread) {
// XXX nspr doesn't seem to be calling the main thread's destructor
// callback, so let's help it out:
nsThread::Exit(NS_STATIC_CAST(nsThread*, gMainThread));
// this will cause gMainThread to be released
PR_SetThreadPrivate
(nsThread::kIThreadSelfIndex, NULL);
// don't keep a dangling reference
gMainThread = NULL;
// nsrefcnt cnt;
// NS_RELEASE2(gMainThread, cnt);
// NS_WARN_IF_FALSE(cnt == 0, "Main thread being held past XPCOM
shutdown.");
}
}
fix the destructor in xpcom/ds/nsDirectoryService.cpp...
nsDirectoryService::~nsDirectoryService()
{
leave everything as is, add:
mService = NULL;
}
Comment 2•25 years ago
|
||
setting bug status to New and adding patch keyword
Updated•25 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → M20
Comment 6•25 years ago
|
||
Can we, for now, just eliminate the actual shutdown and second startup code
except in debug environments or environments where people are looking for
leaks?
Comment 7•25 years ago
|
||
ray, this is an embedded use of xpcom. So that we do not leak all over the
place, we need to allow for a shutdown - startup.
Lets address the problems and not bandaide the problem.
Comment 8•25 years ago
|
||
OK. My answer is to remove the function NS_ShutdownXPCOM, and have a single
function that can be called anywhere to track outstanding leaks. Actual
shutdown of XPCOM will not happen soon. I will fix this in M18 if you agree
with this solution. Otherwise, it becomes future.
This is not acceptable for componentization because object based on XPCOM will
leak a huge chunk of memory into their host's address space with no way of
cleaning it up. Basically, as far as the host process is concerned, it creates
some component (GTK, ActiveX, whatever) and when it decides to delete it, all
the memory that the component used should go too. If we delete NS_TermXPCOM then
that's obviously impossible.
If you're concerned about services and marshalled pointers still being alive and
refcounted when NS_TermXPCOM is called, then we need to establish some rules of
behaviour for these objects. Perhaps services should be singletons for instance
that ignore calls to AddRef and *always* go away when the Term happens? Anyone
who tries to call them after is in error and a crash is their just desserts. Or
maybe services/marshalled pointers should return NS_ERROR_XPCOM_NOT_INITIALISED
if they are called when XPCOM is not initialised?
Comment 10•25 years ago
|
||
Perhaps we could schedule meetings this week, starting today, identifying the
real requirements you are trying to solve and all the XPCOM changes that are
required for this enhancement.
Updated•25 years ago
|
Target Milestone: M20 → Future
Comment 11•25 years ago
|
||
Assigning rest of xpcom stuff to myself (from Ray).
Assignee: rayw → warren
Status: ASSIGNED → NEW
Target Milestone: Future → mozilla1.0
Updated•25 years ago
|
QA Contact: leger → kandrot
Comment 12•24 years ago
|
||
reasigning warren bugs to default component owners.
Assignee: warren → kandrot
QA Contact: kandrot → scc
Target Milestone: mozilla1.0 → ---
Updated•24 years ago
|
Target Milestone: --- → mozilla1.1
Comment 14•23 years ago
|
||
moving out based on my workload. Yell, if you have a problem.
Keywords: helpwanted
Target Milestone: mozilla1.1alpha → Future
Updated•23 years ago
|
Summary: NS_ShutdownXPCOM followed by NS_InitXPCOM → NS_ShutdownXPCOM followed by NS_InitXPCOM leaks and crashes
Comment 15•23 years ago
|
||
per discussion w/ dougt, topembed minusing this bug.
Updated•19 years ago
|
Assignee: dougt → nobody
QA Contact: scc → xpcom
Updated•19 years ago
|
Assignee: nobody → benjamin
Severity: normal → enhancement
OS: Windows 95 → All
Hardware: PC → All
Target Milestone: Future → mozilla1.9alpha
Updated•19 years ago
|
Assignee: benjamin → nobody
Updated•16 years ago
|
Priority: P3 → P4
Target Milestone: mozilla1.9alpha1 → Future
Comment 16•16 years ago
|
||
bsmedberg, can you tell whether this bug is (still) valid?
Comment 17•16 years ago
|
||
Yes, I'd like this to remain open.
Comment 18•14 years ago
|
||
I'm now going to reverse my 2009-self and close this, it's not something we are actually doing or planning on doing.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•