Closed
Bug 336914
Opened 20 years ago
Closed 20 years ago
mAdoptFreeCount not maintained correctly
Categories
(Core :: XPCOM, defect, P2)
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
Attachments
(1 file)
|
5.55 KB,
patch
|
darin.moz
:
review+
darin.moz
:
superreview+
|
Details | Diff | Splinter Review |
I decided to track down this output from startup + shutdown:
=> mAdoptCount: 1507
=> mAdoptFreeCount: 1478 -- LEAKED 29 !!!
As far as I can tell, this happens because mAdoptFreeCount is incorrect. Specifically, calling
nsTAdoptingString_CharT::operator=( const self_type& str )
will increment mAdoptCount by 1 but not change mAdoptFreeCount, which is wrong since the buffer just got passed from one string to another. Unfortunately, all the logging code is in a different file (nsSubString.cpp, to be exact). So I can't just add a logging statement here.
Perhaps we should simply move all of nsTString.cpp (which is just the constructor in question) into nsTSubString.cpp?
Comment 1•20 years ago
|
||
Good catch. You could just avoid calling Adopt and set the member fields directly. The important thing to do is to properly finalize the existing string who's members are being replaced with the adopted value.
| Assignee | ||
Comment 2•20 years ago
|
||
For what it's worth, I found this by just adding ctor/dtor logging for the buffer when we adopt/adoptfree and then looking at the adopt stacks not matched by free.... Not sure whether we want to add that to the tree permanently; let me know.
Comment 3•20 years ago
|
||
Yeah, even if only as an optional #ifdef, I think that'd be great.
| Assignee | ||
Comment 4•20 years ago
|
||
Attachment #221117 -
Flags: superreview?(darin)
Attachment #221117 -
Flags: review?(darin)
| Assignee | ||
Updated•20 years ago
|
Assignee: nobody → bzbarsky
Priority: -- → P2
Target Milestone: --- → mozilla1.9alpha
Comment 5•20 years ago
|
||
Comment on attachment 221117 [details] [diff] [review]
This seems to work
s/refcound/refcount/
Attachment #221117 -
Flags: superreview?(darin)
Attachment #221117 -
Flags: superreview+
Attachment #221117 -
Flags: review?(darin)
Attachment #221117 -
Flags: review+
| Assignee | ||
Comment 6•20 years ago
|
||
Fixed.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Comment 7•20 years ago
|
||
This patch, in combination with the static string detector, blows up on Windows; nsLocalFileWin::Load calls IsFile calls ResolveAndStat which does lots of string manipulation, unfortunately while the static string detector is active.
Note that the static string detector does otherwise work in that it found a host of static strings in nsWindowsHooks[Utils].cpp which I recently fixed.
| Assignee | ||
Comment 8•20 years ago
|
||
I don't really know anything about the static string detector. How does this patch affect it?
Updated•5 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•