Bug 21711 - unnecessary code in _cairo_ft_unscaled_font_map_destroy
Summary: unnecessary code in _cairo_ft_unscaled_font_map_destroy
Status: RESOLVED MOVED
Alias: None
Product: cairo
Classification: Unclassified
Component: freetype font backend (show other bugs)
Version: 1.9.1
Hardware: Other All
: medium normal
Assignee: David Turner
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-12 15:55 UTC by Karl Tomlinson
Modified: 2018-08-25 13:38 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Karl Tomlinson 2009-05-12 15:55:26 UTC
_cairo_ft_unscaled_font_map_destroy is called from
_cairo_ft_font_reset_static_data.

It calls _cairo_ft_unscaled_font_map_pluck_entry on each entry in the hash
table, but there should not be any unscaled_fonts in the hash table at this stage, as they are removed when their last reference is removed.

Even if there were some unscaled_fonts in the hash table, freeing the
unscaled_font while it has references seems a bit strange, and
_cairo_ft_unscaled_font_map_pluck_entry does not do all the destruction that
_cairo_unscaled_font_destroy would do when the last reference is released.

I think it would probably be best to skip _cairo_ft_unscaled_font_map_pluck_entry and just call_cairo_hash_table_destroy which will assert that the hash table has no live entries.
Comment 1 Behdad Esfahbod 2009-05-12 16:12:51 UTC
Humm, what about the zombies?  Search for zombie in the file.
Comment 2 Karl Tomlinson 2012-02-14 11:59:08 UTC
Zombies are font_faces that are owned by an unscaled_font because there are no other references to the font_face, but the unscaled_font still has a reference.

Given there should be no external references to font_faces or scaled_fonts during cairo_debug_reset_static_data and _cairo_scaled_font_reset_static_data has already removed the holdover scaled_fonts, there should not be any references to unscaled_fonts, and so no zombies, at this stage.
Comment 3 Uli Schlachter 2012-02-14 12:39:21 UTC
I put an ASSERT_NOT_REACHED into _cairo_ft_unscaled_font_map_pluck_entry and the test suite didn't crash a single time. So I guess you might have a valid point here. (This is what you were trying to say, right?)
Comment 4 Karl Tomlinson 2012-02-14 13:55:28 UTC
Yes, _cairo_ft_unscaled_font_map_pluck_entry (and the foreach) is unnecessary because there is nothing in the hash_table.
Comment 5 Behdad Esfahbod 2012-02-15 13:35:56 UTC
I don't have time to restudy the full logic there.  You may want to git blame and read the commit logs too.  Other than that, if you can get ickle take a look too, would be nice.  Failing that just push and make sure Firefox keeps working :).
Comment 6 Behdad Esfahbod 2015-05-19 20:10:07 UTC
Ok, I checked the code again.  lgtm.
Comment 7 GitLab Migration User 2018-08-25 13:38:00 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/110.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.