Closed
Bug 175888
Opened 22 years ago
Closed 22 years ago
Calling nsGlobalHistory::CloseDB() must be safe
Categories
(Core Graveyard :: History: Global, defect, P1)
Core Graveyard
History: Global
Tracking
(Not tracked)
VERIFIED
FIXED
mozilla1.0.2
People
(Reporter: KaiE, Assigned: KaiE)
References
Details
(Keywords: topembed+, Whiteboard: [adt2] [ETA 11/15])
Attachments
(1 file, 1 obsolete file)
1.15 KB,
patch
|
timeless
:
review+
alecf
:
superreview+
|
Details | Diff | Splinter Review |
Because of bug 175320, in the future the profile shutdown events will be seen on application shutdown. We must make sure that nsGlobalService does not run into trouble when because of those events, CloseDB will get called twice. I tried to guess whether calling CloseDB() twice is already safe, but I'm having trouble making the decision. The following code is inside CloseDB: ExpireEntries(PR_FALSE /* don't notify */); err = Commit(kSessionCommit); // order is important here - logically smallest objects first mMetaRow = nsnull; if (mTable) mTable->Release(); if (mStore) mStore->Release(); if (mEnv) mEnv->Release(); mTable = nsnull; mEnv = nsnull; mStore = nsnull; Is it ok to execute that twice? Could we possibly check whether mStore is null, and prevent cleanup in that case? I suggest, because OpenDB is returning success if mStore is already set. On the other, CloseDB seems to treat mStore just like one of many objects to clean up.
Assignee | ||
Updated•22 years ago
|
Assignee | ||
Comment 1•22 years ago
|
||
Alec, Blake, do you know the answer?
Comment 2•22 years ago
|
||
hmm.. I would imagine its safe. if mStore is null, then ExpireEntries and Commit should be no-ops.
Comment 3•22 years ago
|
||
Bug 175320 topembed+/nsbeta1+, and is blocked by this bug, so I am marking this one as nsbeta1+/topembed+.
Assignee | ||
Comment 4•22 years ago
|
||
Oops. I notice that ExpireEntries is not a no-op. Actually, it will call OpenDB! CloseDB() -> ExpireEntries() -> RemoveMatchingRows() -> OpenDB()
Comment 5•22 years ago
|
||
oh! that's bad. I guess we need the check at the start of CloseDB...well, I'll review any patches :)
Assignee | ||
Comment 6•22 years ago
|
||
I don't really dare a patch that makes assumptions about the existing code, and I don't want to use any existing state variable to make a decision. I'm attaching a patch that tries to be as safe as possible. The idea of the patch is to avoid executing the code in CloseDB multiple times, if no calls to OpenDB were seen in between. However, as soon as a call to OpenDB was seen, we allow the call to CloseDB, as parts of its action might have become necessary. I'm choosing this approach, because I don't know what could happen between the profile-before-change notification and the actual destruction.
Assignee | ||
Comment 7•22 years ago
|
||
-> me, since it looks I'm writing the patch :)
Assignee: blaker → kaie
Comment 8•22 years ago
|
||
Comment on attachment 103670 [details] [diff] [review] Patch v1 Kai - that is why we have the reviewer system - to catch assumptions like that. This allows you to attempt to write simpler code (i.e. instead of what is written here) and ask your reviewers if you are making too many assumptions. As a reviewer and coauthor of this code, I can vouch for the fact that mStore indicates that the store is open. This code is in fact broken, because nothing ever resets mAvoidMultipleCloseDB, so that once the DB is closed, it will never be closed again. (for example, if you switch profiles once, all future profile switches will leave the DB open) Please just check mStore and return early if mStore is null.
Attachment #103670 -
Flags: needs-work+
Assignee | ||
Comment 9•22 years ago
|
||
> nothing ever resets mAvoidMultipleCloseDB, so that once the DB is closed,
> it will never be closed again. (for example, if you switch profiles once,
> all future profile switches will leave the DB open)
? The reset is happening at the beginning of OpenDB. The avoid flag will get set
to false, the check in CloseDB will fail and the rest of the close function will
get executed.
But I'll attach the simpler patch.
Assignee | ||
Comment 10•22 years ago
|
||
Simpler patch as suggested
Attachment #103670 -
Attachment is obsolete: true
Comment 11•22 years ago
|
||
Comment on attachment 103728 [details] [diff] [review] Patch v2 looks great. sr=alecf
Attachment #103728 -
Flags: superreview+
Assignee | ||
Comment 12•22 years ago
|
||
Chris, Blake, could one of you please review this small patch?
Comment 13•22 years ago
|
||
i think the checkin of this patch can wait until someone urgently needs the changes to land on the 1.0 branch. setting ETA to 11/15 for now.
Whiteboard: [adt2] [ETA Needed] → [adt2] [ETA 11/15]
Assignee | ||
Comment 14•22 years ago
|
||
I need help finding additional reviewers. I pinged both waterson and blaker by private mail 2 weeks ago, but they did not respond.
Comment 15•22 years ago
|
||
as a former owner of history, I hope that my sr= could help count towards a module-owner review. this is pretty basic stuff, so I'd like to say that any reviewer should do.. (that said, waterson is off on other projects, and is probably a bad candidate for reviews)
Attachment #103728 -
Flags: review+
Assignee | ||
Comment 16•22 years ago
|
||
fixed on trunk
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Updated•6 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•