Closed
Bug 197827
Opened 23 years ago
Closed 23 years ago
nsSHEntry::AddChild() leaks
Categories
(Core :: DOM: Navigation, defect)
Core
DOM: Navigation
Tracking
()
RESOLVED
FIXED
People
(Reporter: keeda, Assigned: keeda)
References
()
Details
(Keywords: memory-leak)
Attachments
(1 file, 2 obsolete files)
|
4.13 KB,
patch
|
radha
:
review+
alecf
:
superreview+
|
Details | Diff | Splinter Review |
Shift+Reload on frameset pages appears to be leaking nsSHEntry objects.
For example just visit http://developer.kde.org/~sewardj/docs/ and hit shift+reload.
This seems to be because AddChild does not consider the possibility that there
may be pre-exisiting entries in the same offset possition.
| Assignee | ||
Comment 1•23 years ago
|
||
The surrounding code seems to have a mix of spaces and tabs. Let me know if I
should be using tabs insteads.
| Assignee | ||
Updated•23 years ago
|
Attachment #117473 -
Flags: superreview?(alecf)
Attachment #117473 -
Flags: review?(radha)
Comment 3•23 years ago
|
||
Comment on attachment 117473 [details] [diff] [review]
fix leak by releasing old entry if necessary
wow, damn. good catch.
We really should be using nsCOMArray for mChildren if it is really storing
strong references.
sr=alecf as long as radha agrees this is the right thing. (though again, I'd
prefer switching over to nsCOMArray entirely)
Attachment #117473 -
Flags: review?(radha) → review+
| Assignee | ||
Comment 4•23 years ago
|
||
>We really should be using nsCOMArray for mChildren if it is really storing
>strong references.
Yeah, I looked at doing that. However, thats not totally trivial, and will take
some thought. (e.g. nsCOMArray doesn't seem to have SafeElementAt() ... and so
on.)
Status: NEW → ASSIGNED
| Assignee | ||
Comment 5•23 years ago
|
||
Comment on attachment 117473 [details] [diff] [review]
fix leak by releasing old entry if necessary
Setting the flag that alecf meant, and restoring review request that is still
pending.
Attachment #117473 -
Flags: superreview?(alecf)
Attachment #117473 -
Flags: superreview+
Attachment #117473 -
Flags: review?(radha)
Attachment #117473 -
Flags: review+
| Assignee | ||
Comment 6•23 years ago
|
||
Well it turns out its quite simple to just do the nsCOMArray thing as alecf
suggested. So lets do this instead.
Attachment #117473 -
Attachment is obsolete: true
| Assignee | ||
Updated•23 years ago
|
Attachment #117473 -
Flags: review?(radha)
| Assignee | ||
Updated•23 years ago
|
Attachment #117596 -
Flags: superreview?(alecf)
Attachment #117596 -
Flags: review?(radha)
| Assignee | ||
Comment 7•23 years ago
|
||
Err ... that last patch had a really embarrasing bug. This one should hopefully
be better.
Attachment #117596 -
Attachment is obsolete: true
| Assignee | ||
Comment 8•23 years ago
|
||
Comment on attachment 117598 [details] [diff] [review]
fixed silly bug
Sorry for all the spam.
This one hopefully is good.
Attachment #117598 -
Flags: superreview?(alecf)
Attachment #117598 -
Flags: review?(radha)
Comment 9•23 years ago
|
||
Comment on attachment 117598 [details] [diff] [review]
fixed silly bug
nice cleanup!
again, sr=alecf, as long as radha is the reviewer.
Attachment #117598 -
Flags: superreview?(alecf) → superreview+
Comment 10•23 years ago
|
||
Comment on attachment 117598 [details] [diff] [review]
fixed silly bug
Presuming you have tested this well.
Attachment #117598 -
Flags: review?(radha) → review+
Updated•23 years ago
|
Attachment #117596 -
Flags: superreview?(alecf)
Attachment #117596 -
Flags: review?(radha)
| Assignee | ||
Comment 11•23 years ago
|
||
Browsing around some framset pages in a debug build with this patch throws up
these assestions.
###!!! ASSERTION: nsVoidArray::ElementAt(index past end array) - note on bug 961
08: 'aIndex < Count()', file d:\trunk\mozilla\xpcom\ds\nsVoidArray.h, line 72
Break: at file d:\trunk\mozilla\xpcom\ds\nsVoidArray.h, line 72
---------------------------------------------------------------------------
xpcom.dll!nsDebug::Assertion(const char * aStr=0x100f3c00, const char *
aExpr=0x100f3c50, const char * aFile=0x100f3cbc, int aLine=72) Line 280 +
0xdxpcom.dll!nsVoidArray::ElementAt(int aIndex=0) Line 72 + 0x23 C++
xpcom.dll!nsCOMArray_base::ObjectAt(int aIndex=0) Line 96 C++
xpcom.dll!nsCOMArray_base::ReplaceObjectAt(nsISupports * aObject=0x04b75a5c,
int aIndex=0) Line 89 + 0xc C++
docshell.dll!nsCOMArray<nsISHEntry>::ReplaceObjectAt(nsISHEntry *
aObject=0x04b75a5c, int aIndex=0) Line 173 C++
docshell.dll!nsSHEntry::AddChild(nsISHEntry * aChild=0x04b75a5c, int
aOffset=0) Line 371 C++
---------------------------------------------------------------------------
The problem is that inspite of what the comment in the header file seems to
suggest, nsCOMArray::ReplaceElementAt() is not safe for growing the array to an
aribitrary length (like nsVoidArray::ReplaceElementAt()) is.
I dont want to write ugly code to explicity insert nulls in the array when
needed. So either we go back to the original patch, or maybe nsCOMArray needs
to changed somewhat like so........
diff -u -r1.10 nsCOMArray.cpp
--- nsCOMArray.cpp 18 Jan 2003 14:04:23 -0000 1.10
+++ nsCOMArray.cpp 19 Mar 2003 11:28:12 -0000
@@ -86,7 +86,8 @@
nsCOMArray_base::ReplaceObjectAt(nsISupports* aObject, PRInt32 aIndex)
{
// its ok if oldObject is null here
- nsISupports *oldObject = ObjectAt(aIndex);
+ nsISupports *oldObject =
+ NS_REINTERPRET_CAST(nsISupports*, mArray.SafeElementAt(aIndex));
PRBool result = mArray.ReplaceElementAt(aObject, aIndex);
Thoughts?
Comment 12•23 years ago
|
||
I like that patch to nsCOMArray. sr=alecf on that...
Comment 13•23 years ago
|
||
though I suppose what would be nicer would be to have a SafeObjectAt() where the
casting happens.
Comment 14•23 years ago
|
||
I can not comment on the patch to nsCOMArray. So, please go ahead with alec's
suggestion and any reviews he may want you to get. However, I feel that the
change to nsCOMArray should be tested well before checked in.
| Assignee | ||
Comment 15•23 years ago
|
||
Looks like alecf already checked in that nsCOMArray change which I needed, so
the conversion patch above can go ahead.
> However, I feel that the change to nsCOMArray should be tested well before
> checked in.
Radha, I've tested things like moving back and forth in history while browsing
(and frameset pages specifically) quite a bit. Everything appears fine to me.
Are there any other specific tests available that you would like me to do
before I check this in?
Comment 16•23 years ago
|
||
Since the change is deep in the management of the entries, I think some basic
testing of frames pages (back, forward, reload, shift-reload, using the Go menu)
should do. I guess you can check in what you have.
| Assignee | ||
Comment 17•23 years ago
|
||
I checked this in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Component: History: Session → Document Navigation
QA Contact: kasumi → docshell
You need to log in
before you can comment on or make changes to this bug.
Description
•