Closed Bug 368119 Opened 17 years ago Closed 17 years ago

valgrind warnings writing uninitialized memory to disk cache

Categories

(Core :: Networking: Cache, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dbaron, Assigned: dbaron)

Details

(Keywords: valgrind, Whiteboard: [patch])

Attachments

(1 file)

I originally reopened bug 184614 for this, but I'm filing it now as a separate bug.

On startup, I reliably see a valgrind warning about writing uninitialized memory to disk cache.  One of those warnings is in attachment 252679 [details].

I noticed the problem may be to the effect of mKeyStart on sizeof(nsDiskCacheEntry).
In particular, the sizeof(nsDiskCacheEntry) math in CreateDiskCacheEntry, which could use the offsetof trick that nsDiskCacheEntry::Size uses, or we could just get rid of mKeyStart, which is pretty easy as well.
Attached patch patchSplinter Review
This removes the mKeyStart (which presumably adds 3 bytes of padding for the alignment as well), so that sizeof(nsDiskCacheEntry) is less confusing.  The substantive change this should be causing is reducing the size calculation in CreateDiskCacheEntry, which does two things:
 * reduces the amount of memory allocated
 * reduces the |size| returned to nsDiskCacheMap::WriteDiskCacheEntry

The latter change changes the file index; therefore I chose to bump the cache version, although I'm not sure if that's needed.
Assignee: nobody → dbaron
Status: NEW → ASSIGNED
Attachment #252691 - Flags: superreview?
Attachment #252691 - Flags: review?
Attachment #252691 - Flags: superreview?(darin.moz)
Attachment #252691 - Flags: superreview?
Attachment #252691 - Flags: review?(darin.moz)
Attachment #252691 - Flags: review?
Attachment #252691 - Flags: superreview?(darin.moz)
Attachment #252691 - Flags: superreview+
Attachment #252691 - Flags: review?(darin.moz)
Attachment #252691 - Flags: review+
Checked in to trunk.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Keywords: valgrind
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: