Open
Bug 337120
Opened 19 years ago
Updated 2 years ago
Memory leaks fix for manifest parsing in libjar
Categories
(Core :: Networking: JAR, defect, P3)
Core
Networking: JAR
Tracking
()
NEW
People
(Reporter: alfredkayser, Unassigned)
Details
(Keywords: memory-leak, Whiteboard: [necko-backlog])
Attachments
(1 file, 3 obsolete files)
25.13 KB,
patch
|
taras.mozilla
:
review-
|
Details | Diff | Splinter Review |
Split from bug 214672:
Fixes for memory leaks and such in manifest parsing in libjar.
This code has been partial reviewed in bug 214672.
Overview:
Postpone the ManifestTable creation from nsJAR creation to when it is really needed.
Replaced 'mTotalItemsInManifest' with ManifestTable->Count.
Optimized ReadLine (not strtok nor strlen, just search for \r(\n)
Only nsJARManifestItem when really needed.
Allocate storedSectionItem together with nsJARManifestItem.
Replaced Equals(NS_LIT... with corresponding EqualsLiteral.
Reporter | ||
Comment 1•19 years ago
|
||
Assignee: nobody → alfredkayser
Status: NEW → ASSIGNED
Reporter | ||
Updated•18 years ago
|
Component: Networking: File → Networking: JAR
Updated•18 years ago
|
QA Contact: networking.file → networking.jar
Comment 2•17 years ago
|
||
Alfred, do you think you could unbitrot this and request review?
Keywords: mlk
Reporter | ||
Comment 3•17 years ago
|
||
Attachment #221292 -
Attachment is obsolete: true
Attachment #297605 -
Flags: review?(cbiesinger)
Reporter | ||
Comment 4•17 years ago
|
||
Updated•17 years ago
|
Flags: blocking1.9?
Comment 5•17 years ago
|
||
Any chance we can get a smaller patch isolated to the core memory changes (there are a bunch of other changes in this patch).
Any idea how big the leak is?
Reporter | ||
Comment 6•17 years ago
|
||
Removed the unneeded parts.
The 'leaks' are in multiple places:
1. When an nsJAR is allocated there is always an hashtable allocated for the manifest, even if it is totally not used.
2. During parsing of the manifest, nsJARManifestItem's will be leaked (especially when there are errors in the manifest).
3. Strings allocated for the manifest items are not always freed.
4. Use of autostring for CalculateDigest will also prevent leakage there.
Some other related issues:
A. Passing a null pointer to GetManifestEntriesCount would result in a crash without this patch
Note, until recently signed jars where very rare, but now that FF3 requires/prefers signed jars for installation of extensions and themes, this will happen more and more.
Attachment #297605 -
Attachment is obsolete: true
Attachment #301634 -
Flags: review?(cbiesinger)
Attachment #297605 -
Flags: review?(cbiesinger)
Comment 7•17 years ago
|
||
Thnx alfred for the expln and the new patch. Can we whip up some unit tests for this?
Flags: blocking1.9? → blocking1.9+
Priority: -- → P1
Updated•17 years ago
|
Flags: wanted-next+
Flags: tracking1.9+
Flags: blocking1.9-
Reporter | ||
Comment 8•15 years ago
|
||
See descriptions of earlier versions.
This removes potential memory leaks in manifest parsing, makes the manifest table lazily initialized (as most jar/zips don't have a manifest at all), and replaces nsObjectHashtable with nsClassHashtable.
Attachment #301634 -
Attachment is obsolete: true
Attachment #419544 -
Flags: review?(tglek)
Attachment #301634 -
Flags: review?(cbiesinger)
Reporter | ||
Updated•15 years ago
|
Attachment #419544 -
Attachment is patch: true
Attachment #419544 -
Attachment mime type: application/octet-stream → text/plain
Comment 9•15 years ago
|
||
Comment on attachment 419544 [details] [diff] [review]
V5: Updated to current trunk (hg), and use nsClassHashTable
Since nsJARManifestItems were leaking, consider putting MOZ_COUNT_CTOR/DTOR stuff in the class.
> return mZip.Test(aEntryName);
>@@ -354,59 +345,71 @@ nsJAR::GetInputStreamWithSpec(const nsAC
> NS_IMETHODIMP
> nsJAR::GetCertificatePrincipal(const char* aFilename, nsIPrincipal** aPrincipal)
> {
> //-- Parameter check
> if (!aPrincipal)
> return NS_ERROR_NULL_POINTER;
> *aPrincipal = nsnull;
We are trying to move away from setting outparams AND returning an error code.
>+/*
>+ * Moves pointer to beginning of next line and returns line length
>+ * not including CR/LF.
>+ */
> PRInt32
> nsJAR::ReadLine(const char** src)
> {
This should be a static utility function.
The rest of the patch looks ok to me. I think this could also benefit from testcases.
Comment 10•15 years ago
|
||
Comment on attachment 419544 [details] [diff] [review]
V5: Updated to current trunk (hg), and use nsClassHashTable
this needs a basic testcase for valid/missing/corrupt manifest cases
Attachment #419544 -
Flags: review?(tglek) → review-
Updated•9 years ago
|
Whiteboard: [necko-backlog]
Comment 11•7 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Comment 12•7 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P1 → P3
Updated•3 years ago
|
Assignee: alfredkayser → nobody
Status: ASSIGNED → NEW
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•