Bug 21445 - on windows, we try to remove m_smallCapsFontData from the font cache, but we never added it there
Summary: on windows, we try to remove m_smallCapsFontData from the font cache, but we ...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Tony Chang
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-07 13:47 PDT by Tony Chang
Modified: 2009-03-06 11:52 PST (History)
1 user (show)

See Also:


Attachments
[1/1] Fix a bug where we try to release font data from the font cache when it (787 bytes, patch)
2008-10-07 13:48 PDT, Tony Chang
hyatt: review-
Details | Formatted Diff | Diff
[1/1] Fix a bug where we try to release font data from the font cache when it (2.27 KB, patch)
2008-10-07 14:23 PDT, Tony Chang
hyatt: review-
Details | Formatted Diff | Diff
[1/1] Fix a bug where we try to release font data from the font cache when it (2.52 KB, patch)
2008-10-07 17:06 PDT, Tony Chang
eric: review-
Details | Formatted Diff | Diff
updated changelog (2.68 KB, patch)
2008-12-09 16:16 PST, Tony Chang
darin: review-
Details | Formatted Diff | Diff
remove extra branch (2.65 KB, patch)
2008-12-16 14:41 PST, Tony Chang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Chang 2008-10-07 13:47:44 PDT
This causes an assert to be triggered in FontCache::releaseFontData.  Patch coming up...
Comment 1 Tony Chang 2008-10-07 13:48:32 PDT
Created attachment 24158 [details]
[1/1] Fix a bug where we try to release font data from the font cache when it

was never added to the font cache in the first place.
---
 WebCore/platform/graphics/SimpleFontData.cpp |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
Comment 2 Dave Hyatt 2008-10-07 13:55:56 PDT
Comment on attachment 24158 [details]
[1/1] Fix a bug where we try to release font data from the font cache when it

I think a better fix here would be to fix the Windows port to actually cache small caps font data in the non-custom-font case.
Comment 3 Tony Chang 2008-10-07 14:23:12 PDT
Created attachment 24161 [details]
[1/1] Fix a bug where we try to release font data from the font cache when it

was never added to the font cache in the first place.
---
 WebCore/ChangeLog                                  |   12 ++++++++++++
 .../platform/graphics/win/SimpleFontDataWin.cpp    |    8 +++-----
 2 files changed, 15 insertions(+), 5 deletions(-)
Comment 4 Dave Hyatt 2008-10-07 14:30:54 PDT
Comment on attachment 24161 [details]
[1/1] Fix a bug where we try to release font data from the font cache when it

You don't want to cache a custom font.  You only want to patch the non-custom-font  code path.  Technically on Windows the small caps font won't ever be shared, but for cross-platform consistency it's better to have that in the cache even if it's pointless. :)

However I see an additional bug, namely that small caps font data in the custom font path is leaking.  The SimpleFontData destructor is not deleting m_smallCapsFontData in the custom font case.
Comment 5 Tony Chang 2008-10-07 17:06:57 PDT
Created attachment 24163 [details]
[1/1] Fix a bug where we try to release font data from the font cache when it

was never added to the font cache in the first place.
---
 WebCore/ChangeLog                                  |   12 ++++++++++++
 WebCore/platform/graphics/SimpleFontData.cpp       |    3 ++-
 .../platform/graphics/win/SimpleFontDataWin.cpp    |    6 ++----
 3 files changed, 16 insertions(+), 5 deletions(-)
Comment 6 Eric Seidel (no email) 2008-11-14 10:39:05 PST
Comment on attachment 24163 [details]
[1/1] Fix a bug where we try to release font data from the font cache when it

Sorting the review queue, since it's pretty full.  Hyatt is your man for this patch.  Mitz probably also has some font expertise these days.
Comment 7 Dave Hyatt 2008-12-05 09:42:41 PST
Comment on attachment 24163 [details]
[1/1] Fix a bug where we try to release font data from the font cache when it

r=me
Comment 8 Eric Seidel (no email) 2008-12-08 15:45:47 PST
Comment on attachment 24163 [details]
[1/1] Fix a bug where we try to release font data from the font cache when it

This really should have a layout test.  Marking r- due to lack of layout test.  If you upload a patch with a layout test I'm happy to land.  Or, if you can explain how this is untestable I'm happy to land.

(p.s. ideally ChangeLogs should have links to the bugzilla bug in them.  Also in general you should replace "WARNING:" with either the location of the test case or an explanation why it's not possible)
Comment 9 Tony Chang 2008-12-09 16:16:04 PST
Created attachment 25902 [details]
updated changelog

I tried to create a layout test that causes the font cache to be purged, but I was unable to do it.  Instead, I updated the changelog.
Comment 10 Darin Adler 2008-12-10 14:39:15 PST
Comment on attachment 25902 [details]
updated changelog

It's weak when the code that allocates m_smallCapsFontData and the code that destroys it are so far apart. This makes it hard to be sure we're using it right. I think that's an argument for moving the FontCache::releaseFontData call from SimpleFontData::~SimpleFontData into the SimpleFontData::platformDestroy functions for the Mac platform. I think if we did just that it would fix this bug.

> +    } else if (m_smallCapsFontData)
> +        delete m_smallCapsFontData;

This patch is definitely wrong for some platforms other than Windows. If isCustomFont() is false, then both SimpleFontData::~SimpleFontData and SimpleFontData::platformDestroy will call delete on m_smallCapsFontData. Double deletes are not good.

By the way, there's no need for an if here, because C++ already does nothing if it's passed 0. Specifying the if just adds an extra branch, and would only be justified in unusual circumstances.
Comment 11 Tony Chang 2008-12-16 14:27:03 PST
It looks like on mac m_smallCapsFontData is allocated using new if it's a custom font.
http://trac.webkit.org/browser/trunk/WebCore/platform/graphics/mac/SimpleFontDataMac.mm#L294
So it doesn't look like a double free.

I'll make a new patch which doesn't have the extra "if".
Comment 12 Tony Chang 2008-12-16 14:41:48 PST
Created attachment 26068 [details]
remove extra branch
Comment 13 mitz 2009-02-09 13:27:02 PST
I think this was fixed in <http://trac.webkit.org/changeset/40729>. You may want to post and updated patch to actually get the small caps font from the cache on windows.
Comment 14 Tony Chang 2009-02-09 13:40:18 PST
The original bug was fixed, so I'm marking this bug as invalid.