After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 341138 - Using TTC font, Gtk2 programs begin to eating big memory and have many cpu usage.
Using TTC font, Gtk2 programs begin to eating big memory and have many cpu u...
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.13.x
Other All
: Normal critical
: ---
Assigned To: Behdad Esfahbod
pango-maint
Depends on:
Blocks:
 
 
Reported: 2006-05-09 13:39 UTC by sangu
Modified: 2006-05-31 07:46 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
dmesg log (15.23 KB, text/plain)
2006-05-25 11:52 UTC, unz
  Details
use correct offset when loading opentype table (455 bytes, patch)
2006-05-25 20:32 UTC, Yong Li
committed Details | Review

Description sangu 2006-05-09 13:39:30 UTC
Please describe the problem:
After updating pango to 1.13.0.

Connecting a web page with firefox-1.5.0.3 (using pangotext), firefox begins to
eating big memory(system all memory).

the web page is http://gitweb.freedesktop.org/?p=cairo;a=log

Steps to reproduce:
1. Update pango to 1.13.0
2. Connect http://gitweb.freedesktop.org/?p=cairo;a=log with firefox using pangotext
3. 


Actual results:


Expected results:


Does this happen every time?
yes

Other information:
This problem doesn't happen in cairo 1.1.6 and pango 1.12.1.

OS : Fedora development 20060509

cairo 1.1.6 gtk2-2.9.0
Comment 1 Ronny V. Vindenes 2006-05-11 15:18:50 UTC
I see this too, but when using the asian fonts (batang.ttc, gulim.ttc, mingliu.ttc, msgothic.ttc, msmincho.ttc and simsun.ttc) from microsoft. The 3511 other fonts installed on the system does not appear to trigger this bug.

The bug affects all pango using programs I've tested.
Comment 2 Behdad Esfahbod 2006-05-11 20:27:22 UTC
We cannot do much without having access to the fonts.
Comment 3 sangu 2006-05-12 01:26:58 UTC
[...](In reply to comment #2)
> We cannot do much without having access to the fonts.
> 
$wget ftp://ftp.haansoftlinux.com/pub/haansoftlinux/OS/2005/Workstation/RPMS/hanyang-ttf-2.0-2hs.noarch.rpm

$rpm -ql hanyang-ttf* 
/usr/share/fonts/hanyang/Batang.ttf
/usr/share/fonts/hanyang/Batangche.ttf
/usr/share/fonts/hanyang/Dotum.ttf
/usr/share/fonts/hanyang/Dotumche.ttf
/usr/share/fonts/hanyang/Gulim.ttf
/usr/share/fonts/hanyang/Gulimche.ttf
[...]

this fonts have sbit (embedded bitmap truetype fonts) and are korean font.
Comment 4 sangu 2006-05-12 05:04:24 UTC
Please see : https://bugs.freedesktop.org/show_bug.cgi?id=4705

Related this bug 341138 ? 
Comment 5 sangu 2006-05-17 09:53:49 UTC
Using ttc (font collection) font, gtk2 program has many memory and cpu usage.

ftp://ftp.haansoftlinux.com/pub/haansoftlinux/OS/2005/Workstation/RPMS/hanyang-ttf-2.0-2hs.noarch.rpm
Sorry, this package doesn't have ttc font.
Comment 6 Behdad Esfahbod 2006-05-17 22:04:02 UTC
Wat are TTC fonts?
Comment 7 sangu 2006-05-17 23:04:22 UTC
 http://sparcs.kaist.ac.kr/~pcpenpal/fonts/ has two ttc fonts  for test.
the fonts are batang.ttc and gulim.ttc.

(In reply to comment #6)
> Wat are TTC fonts?
> 

http://lists.freedesktop.org/archives/fontconfig/2003-November/000716.html
.ttc files are just files with multiple fonts; fontconfig has an FC_INDEX 
value which marks the font entry within a file.

Comment 8 unz 2006-05-25 11:52:40 UTC
Created attachment 66181 [details]
dmesg log
Comment 9 unz 2006-05-25 11:53:40 UTC
Comment on attachment 66181 [details]
dmesg log

Pango > 1.13.0 eats all memory in gentoo too with media-fonts/mikachan-font
Comment 10 Yong Li 2006-05-25 20:32:21 UTC
Created attachment 66222 [details] [review]
use correct offset when loading opentype table
Comment 11 Yong Li 2006-05-25 20:34:36 UTC
(In reply to comment #9)
> (From update of attachment 66181 [details] [edit])
> Pango > 1.13.0 eats all memory in gentoo too with media-fonts/mikachan-font
> 

The mikachan-font is also a truetype collection font, i.e with a suffix of ttc, isn't it? I believe the problem with ttc fonts is in the opentype table loading code. It incorrectly assumes that the table offset values are relative to each  individual font, but per opentype spec they are relative to the beginning of *font file*. As a result pango reads in some garbage when loading opentype table, most commonly GSUB, which in turn leads to bogus large size of table contents and quickly results in memory exhaustion. The attached one liner patch should fix it. 
Comment 12 Behdad Esfahbod 2006-05-25 21:15:23 UTC
Ok, cool.  I've written to David Turner to comment on the patch.

This is also a problem that HarfBuzz doesn't really validate the font...
Comment 13 unz 2006-05-26 20:52:29 UTC
you rocks, men! 
problem solved for me with the proposed patch applied against pango-1.13.1.

It was impossible for me to start X because i use mikachan as default font, now i'm happy with my full-updated gnome-2.15.2
Comment 14 Yong Li 2006-05-31 05:46:14 UTC
(In reply to comment #12)

Here's the relevant text from opentype spec on microsoft's webpage. Note especially the last sentence.

<quote>
The TTC file must contain a complete Offset Table and Table Directory for each font. A TTC file Table Directory has exactly the same format as a TTF file Table Directory. The table offsets in all Table Directories within a TTC file are measured from the beginning of the TTC file.
</quote>

You can find this on this page, http://www.microsoft.com/typography/otspec/otff.htm
Scroll down, it's the second paragraph under the subsection "The TTC File Structure" in section "TrueType Collections".
Comment 15 Behdad Esfahbod 2006-05-31 07:46:28 UTC
Thanks.  Committed to HEAD, pango-1-12 branch, and HarfBuzz.

2006-05-31  Behdad Esfahbod  <behdad@gnome.org>

        Bug 341138 – Using TTC font, Gtk2 programs begin to eating big memory
        and have many cpu usage.
        Patch from Yong Li.

        * pango/opentype/ftglue.c (_hb_ftglue_face_goto_table): TrueType table
        offsets are absolute, not relative.