Closed Bug 391491 Opened 14 years ago Closed 14 years ago

Windows trace-malloc needs to override new[] and delete[]


(Core :: General, defect)

Windows XP
Not set





(Reporter: dbaron, Assigned: dbaron)



(2 files, 1 obsolete file)

With Windows trace-malloc, I'm currently seeing allocations done with new[] all showing up as leaked, since new[] seems to call through to new, but delete[] doesn't call through to delete.  Or something like that.  Maybe it has to with offsetting pointers for the stored object count (which is needed to call the right destructors) at different places.

Overriding both new[] and delete[] seems to fix the log of shutdown leaks, but I'm not sure it's the right thing to do.  I need to investigate further tomorrow.
Yeah, that fixes --shutdown-leaks but makes leakstats on the log generated by --trace-malloc give a negative number of leaked allocations.  So it's making is double-count somewhere...
That patch had a typo; I'll test if this one is better tomorrow, or if it needs tweaks for underlying asymmetry.
Attachment #275935 - Attachment is obsolete: true
This adds suppression around the calls to the original allocation functions in case they call each other.  It doesn't fix the negative allocation count I was seeing, though (perhaps due to not starting up until we're into main), but I think it's probably necessary to avoid some errors in the logs.
Attachment #275995 - Flags: review?(brendan)
Attachment #275946 - Flags: review?(brendan)
Comment on attachment 275946 [details] [diff] [review]
patch to override both new[] and delete[]

r=me, looks right, if it works, commit at will!

Attachment #275946 - Flags: review?(brendan)
Attachment #275946 - Flags: review+
Comment on attachment 275995 [details] [diff] [review]
add suppression around calls to original functions

get_tm_thread might want to be tm_get_thread or some such, just to follow some anal-retentive naming convention that wards off name collision in my dreams.

Attachment #275995 - Flags: review?(brendan)
Attachment #275995 - Flags: review+
Patches checked in to trunk, 2007-08-10 15:21 -0700 and 15:22 -0700.
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.