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)

defect

Tracking

()

People

(Reporter: alfredkayser, Unassigned)

Details

(Keywords: memory-leak, Whiteboard: [necko-backlog])

Attachments

(1 file, 3 obsolete files)

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.
Assignee: nobody → alfredkayser
Status: NEW → ASSIGNED
Component: Networking: File → Networking: JAR
QA Contact: networking.file → networking.jar
Alfred, do you think you could unbitrot this and request review?
Keywords: mlk
Attachment #221292 - Attachment is obsolete: true
Attachment #297605 - Flags: review?(cbiesinger)
Flags: blocking1.9?
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?
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)
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
Flags: wanted-next+
Flags: tracking1.9+
Flags: blocking1.9-
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)
Attachment #419544 - Attachment is patch: true
Attachment #419544 - Attachment mime type: application/octet-stream → text/plain
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 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-
Whiteboard: [necko-backlog]
Priority: P1 → P3
Assignee: alfredkayser → nobody
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: