Changeset 19843 in webkit


Ignore:
Timestamp:
Feb 24, 2007 6:14:54 PM (17 years ago)
Author:
ggaren
Message:

LayoutTests:

Reviewed by Darin Adler.


Layout tests for BidiRun leaks.


  • fast/leaks/001-expected.txt: Added.
  • fast/leaks/001.html: Added.
  • fast/leaks/002-expected.txt: Added.
  • fast/leaks/002.html: Added.

WebCore:

Reviewed by Darin Adler.


Fixed <rdar://problem/4987649> leaks in BidiRun::operator new seen while
running WebKit unit tests


In bidi.cpp, some functions allocate BidiRuns and put them in a global data
structure, while others uses the BidiRuns in the global data structure.
The caller is responsible for knowing which functions may allocate runs
and which may use them, and calling deleteBidiRuns() at the appropriate time.

The fix is to add some calls to deleteBidiRuns() where they were missing.


I also added a BidiRun counter because these two leaks were introduced by
our two bidi.cpp experts, so the odds that leaks will creep in again
in the future seem pretty high.

  • rendering/bidi.cpp: (WebCore::RenderBlock::bidiReorderCharacters): Added missing call to deleteBidiRuns(). (WebCore::BidiRunCounter::~BidiRunCounter): (WebCore::BidiRun::operator delete): (WebCore::RenderBlock::layoutInlineChildren): Added missing call to deleteBidiRuns(). Moved call to deleteBidiRuns() to same scope as call to bidiReorderLine(), to emphasize that they go together like new/delete. In theory, the old code was just as good, but I didn't want to rely on theory.

WebKitTools:

Reviewed by Darin Adler.


  • Scripts/run-webkit-tests: Stop ignoring BidiRun leaks, now that they're fixed.
Location:
trunk
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r19840 r19843  
     12007-02-24  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Darin Adler.
     4       
     5        Layout tests for BidiRun leaks.
     6       
     7        * fast/leaks/001-expected.txt: Added.
     8        * fast/leaks/001.html: Added.
     9        * fast/leaks/002-expected.txt: Added.
     10        * fast/leaks/002.html: Added.
     11
    1122007-02-24  Alexey Proskuryakov  <ap@webkit.org>
    213
  • trunk/WebCore/ChangeLog

    r19842 r19843  
     12007-02-24  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Darin Adler.
     4       
     5        Fixed <rdar://problem/4987649> leaks in BidiRun::operator new seen while
     6        running WebKit unit tests
     7       
     8        In bidi.cpp, some functions allocate BidiRuns and put them in a global data
     9        structure, while others uses the BidiRuns in the global data structure.
     10        The caller is responsible for knowing which functions may allocate runs
     11        and which may use them, and calling deleteBidiRuns() at the appropriate time.
     12
     13        The fix is to add some calls to deleteBidiRuns() where they were missing.
     14       
     15        I also added a BidiRun counter because these two leaks were introduced by
     16        our two bidi.cpp experts, so the odds that leaks will creep in again
     17        in the future seem pretty high.
     18
     19        * rendering/bidi.cpp:
     20        (WebCore::RenderBlock::bidiReorderCharacters): Added  missing call to
     21        deleteBidiRuns().
     22        (WebCore::BidiRunCounter::~BidiRunCounter):
     23        (WebCore::BidiRun::operator delete):
     24        (WebCore::RenderBlock::layoutInlineChildren): Added missing call to
     25        deleteBidiRuns(). Moved call to deleteBidiRuns() to same scope as call to
     26        bidiReorderLine(), to emphasize that they go together like new/delete.
     27        In theory, the old code was just as good, but I didn't want to rely on
     28        theory.
     29
    1302007-02-24  David Harrison  <harrison@apple.com>
    231
  • trunk/WebCore/rendering/bidi.cpp

    r19717 r19843  
    3030#include "FrameView.h"
    3131#include "InlineTextBox.h"
     32#include "Logging.h"
    3233#include "RenderArena.h"
    3334#include "RenderLayer.h"
     
    112113static void embed(Direction, BidiState&);
    113114static void appendRun(BidiState&);
     115static void deleteBidiRuns(RenderArena*);
    114116
    115117void RenderBlock::bidiReorderCharacters(Document* document, RenderStyle* style, CharacterBuffer& characterBuffer)
     
    169171    }
    170172
    171     // Tear down temporary RenderBlock and RenderText
     173    // Tear down temporary RenderBlock, RenderText, and BidiRuns
    172174    block->removeChild(text);
    173175    text->destroy();
    174176    block->destroy();
     177    deleteBidiRuns(document->renderArena());
    175178}
    176179
     
    213216
    214217#ifndef NDEBUG
     218WTFLogChannel LogWebCoreBidiRunLeaks =  { 0x00000000, "", WTFLogChannelOn };
     219
     220struct BidiRunCounter {
     221    static int count;
     222    ~BidiRunCounter()
     223    {
     224        if (count)
     225            LOG(WebCoreBidiRunLeaks, "LEAK: %d BidiRun\n", count);
     226    }
     227};
     228int BidiRunCounter::count = 0;
     229static BidiRunCounter bidiRunCounter;
     230
    215231static bool inBidiRunDestroy;
    216232#endif
     
    232248void* BidiRun::operator new(size_t sz, RenderArena* renderArena) throw()
    233249{
     250#ifndef NDEBUG
     251    ++BidiRunCounter::count;
     252#endif
    234253    return renderArena->allocate(sz);
    235254}
     
    237256void BidiRun::operator delete(void* ptr, size_t sz)
    238257{
     258#ifndef NDEBUG
     259    --BidiRunCounter::count;
     260#endif
    239261    assert(inBidiRunDestroy);
    240262
     
    16901712            }
    16911713            end = findNextLineBreak(start, bidi);
    1692             if (start.atEnd())
     1714            if (start.atEnd()) {
     1715                deleteBidiRuns(renderArena());
    16931716                break;
     1717            }
    16941718            if (!isLineEmpty) {
    16951719                bidiReorderLine(start, end, bidi);
     
    17231747                            lineBox->addHighlightOverflow();
    17241748#endif
    1725 
    1726                         deleteBidiRuns(renderArena());
    17271749                    }
    17281750                }
     1751
     1752                deleteBidiRuns(renderArena());
    17291753               
    17301754                if (end == start) {
  • trunk/WebKitTools/ChangeLog

    r19839 r19843  
     12007-02-24  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Darin Adler.
     4       
     5        * Scripts/run-webkit-tests: Stop ignoring BidiRun leaks, now that they're
     6        fixed.
     7
    182007-02-24  Krzysztof Kowalczyk  <kkowalczyk@gmail.com>
    29
  • trunk/WebKitTools/Scripts/run-webkit-tests

    r19798 r19843  
    853853        "NSURLCache cachedResponseForRequest", # leak in CFURL cache, Radar 4768430
    854854        "CGImageSourceGetPropertiesAtIndex", # leak apparently in CG, Radar 4628809
    855         "BidiRun::operator new", # leak in WebCore, Radar 4987649
    856855        "gldGetString" # leak apparently in OpenGL, Radar 5013699
    857856    );
Note: See TracChangeset for help on using the changeset viewer.