Bug 45472 - Memory leak in red/black tree
Summary: Memory leak in red/black tree
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Kenneth Russell
URL:
Keywords:
Depends on:
Blocks: 44729
  Show dependency treegraph
 
Reported: 2010-09-09 10:51 PDT by Kenneth Russell
Modified: 2010-09-09 13:08 PDT (History)
2 users (show)

See Also:


Attachments
Patch (11.79 KB, patch)
2010-09-09 11:05 PDT, Kenneth Russell
jamesr: review+
kbr: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Russell 2010-09-09 10:51:54 PDT
While testing the GPU accelerated path rendering code, a memory leak was discovered and tracked down to the fact that the red/black tree was allocating its nodes using operator new directly rather than the arena class.
Comment 1 Kenneth Russell 2010-09-09 11:05:49 PDT
Created attachment 67063 [details]
Patch

From the ChangeLog:

Fixed memory leak in red/black tree where it was using operator new directly to allocate its internal nodes rather than the arena with which it was configured. Added allocateObject variant to arena supporting single-argument constructors. Added test to red/black tree unit tests to cover this functionality, and refactored TrackedAllocator into helper file to share between arena and red/black tree tests.
Comment 2 James Robinson 2010-09-09 11:11:56 PDT
Comment on attachment 67063 [details]
Patch

Suggestion: ad a private override for operator new on PODRedBlackTree::Node to avoid this sort of bug in the future.
Comment 3 Kenneth Russell 2010-09-09 11:18:01 PDT
(In reply to comment #2)
> (From update of attachment 67063 [details])
> Suggestion: ad a private override for operator new on PODRedBlackTree::Node to avoid this sort of bug in the future.

This is a good suggestion. I tried it, but unfortunately overriding "void* operator new(size_t size)" on this type prevents placement new from working for the type, which is used by the arena.
Comment 4 Kenneth Russell 2010-09-09 11:21:17 PDT
Committed r67099: <http://trac.webkit.org/changeset/67099>