bugThe FreeType Project - Bugs: bug #16631, Two additional memory leaks in...

 
 

bug #16631: Two additional memory leaks in 2.2.1

Submitted by:  Derek Clegg <derek>
Submitted on:  Fri 19 May 2006 06:27:50 PM UTC  
 
Severity: 3 - NormalItem Group: Incorrect behaviour
Status: FixedPrivacy: Public
Assigned to: suzuki toshiya <mpsuzuki>Open/Closed: Closed
Planned Release: 2.3.0

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 19 May 2006 11:18:02 PM UTC, comment #1:

Thank you, I reproduced the reported memory leak and checked that your patch can fix them. I applied your patches in CVS.

[original leaky cases]
env FT2_DEBUG_MEMORY=7 ./ftdump /mnt1/MacDynaFont/50Font/DFPBunTyouMeiTaiW2 2>&1 | sed s/sssa/mpsuzuki/g
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadAt: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_Open: could not open `/mnt1/MacDynaFont/50Font/%DFPBunTyouMeiTaiW2'
FT_Stream_Open: could not open `/mnt1/MacDynaFont/50Font/.AppleDouble/DFPBunTyouMeiTaiW2'
tt_face_build_cmaps: broken cmap sub-table ignored!
There is 1 face in this file.
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadAt: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_Open: could not open `/mnt1/MacDynaFont/50Font/%DFPBunTyouMeiTaiW2'
FT_Stream_Open: could not open `/mnt1/MacDynaFont/50Font/.AppleDouble/DFPBunTyouMeiTaiW2'
tt_face_build_cmaps: broken cmap sub-table ignored!

----- Face number: 0 -----

font name entries
family: DFPBunChoMin-W2
style: Regular
postscript: DFBunChoMin-W2-90pv-RKSJ-H

font type entries
FreeType driver: truetype
sfnt wrapped: yes
type: scalable
direction: horizontal, vertical
fixed width: no
glyph names: yes
EM size: 1000
global BBox: (0,-140):(999,860)
ascent: 860
descent: -140
text height: 1000
glyph count: 8717

charmaps
0: platform 1, encoding 0
FreeType Memory Dump: current=160 max=6086880 total=12151095 count=4
block block sizes sizes sizes source
count high sum highsum max location
-------------------------------------------------
0 1 0 5989484 5989484 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:1361
0 2 0 69736 34868 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/ttmtx.c:171
0 1 0 16384 16384 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:3660
0 3 0 4248 1416 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/smooth/ftgrays.c:2106
0 1 0 2060 2060 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/raster/ftraster.c:3229
0 20 0 1168 196 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:3415
0 1 0 840 840 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/ttload.c:719
0 1 0 820 820 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:962
0 8 0 704 88 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftgloadr.c:76
0 1 0 272 272 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/ttload.c:319
4 6 160 240 40 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:132
0 4 0 214 57 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftrfork.c:672
0 1 0 196 196 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:3653
0 1 0 160 160 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:364
0 2 0 128 116 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:1970
0 1 0 52 52 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:965
0 1 0 49 49 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftrfork.c:439
0 4 0 48 12 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:3100
0 1 0 40 40 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:220
0 1 0 40 40 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:1145
0 1 0 27 27 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/sfdriver.c:264
0 2 0 24 16 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/sfobjs.c:122
0 1 0 24 24 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:2702
0 2 0 22 15 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/sfobjs.c:279
0 1 0 12 12 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:1746
0 1 0 4 4 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/sfobjs.c:418
0 1 0 4 4 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftrfork.c:182
0 1 0 4 4 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:2717
------------------------------------------------
leaked memory block at address 0x80d18f8, size 40 in (/home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:132)
leaked memory block at address 0x80bfa68, size 40 in (/home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:132)
leaked memory block at address 0x80bf990, size 40 in (/home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:132)
leaked memory block at address 0x80bfb28, size 40 in (/home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:132)
FreeType: total memory allocations = 12151095
FreeType: maximum memory footprint = 6086880
FreeType.Debug: FreeType: 160 bytes of memory leaked in 4 blocks

[patched version]
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadAt: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_Open: could not open `/mnt1/MacDynaFont/50Font/%DFPBunTyouMeiTaiW2'
FT_Stream_Open: could not open `/mnt1/MacDynaFont/50Font/.AppleDouble/DFPBunTyouMeiTaiW2'
tt_face_build_cmaps: broken cmap sub-table ignored!
There is 1 face in this file.
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadAt: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_ReadLong: invalid i/o; pos = 0x0, size = 0x0
FT_Stream_Open: could not open `/mnt1/MacDynaFont/50Font/%DFPBunTyouMeiTaiW2'
FT_Stream_Open: could not open `/mnt1/MacDynaFont/50Font/.AppleDouble/DFPBunTyouMeiTaiW2'
tt_face_build_cmaps: broken cmap sub-table ignored!

----- Face number: 0 -----

font name entries
family: DFPBunChoMin-W2
style: Regular
postscript: DFBunChoMin-W2-90pv-RKSJ-H

font type entries
FreeType driver: truetype
sfnt wrapped: yes
type: scalable
direction: horizontal, vertical
fixed width: no
glyph names: yes
EM size: 1000
global BBox: (0,-140):(999,860)
ascent: 860
descent: -140
text height: 1000
glyph count: 8717

charmaps
0: platform 1, encoding 0
FreeType Memory Dump: current=0 max=6086760 total=12151095 count=0
block block sizes sizes sizes source
count high sum highsum max location
-------------------------------------------------
0 1 0 5989484 5989484 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:1361
0 2 0 69736 34868 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/ttmtx.c:171
0 1 0 16384 16384 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:3659
0 3 0 4248 1416 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/smooth/ftgrays.c:2106
0 1 0 2060 2060 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/raster/ftraster.c:3229
0 20 0 1168 196 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:3414
0 1 0 840 840 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/ttload.c:719
0 1 0 820 820 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:962
0 8 0 704 88 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftgloadr.c:76
0 1 0 272 272 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/ttload.c:319
0 4 0 214 57 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftrfork.c:671
0 1 0 196 196 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:3652
0 1 0 160 160 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:364
0 2 0 128 116 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:1969
0 3 0 120 40 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:132
0 1 0 52 52 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:965
0 1 0 49 49 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftrfork.c:439
0 4 0 48 12 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:3099
0 1 0 40 40 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:220
0 1 0 40 40 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:1145
0 1 0 27 27 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/sfdriver.c:264
0 1 0 24 24 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:2701
0 2 0 24 16 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/sfobjs.c:122
0 2 0 22 15 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/sfobjs.c:279
0 1 0 12 12 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:1745
0 1 0 4 4 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/sfnt/sfobjs.c:418
0 1 0 4 4 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftobjs.c:2716
0 1 0 4 4 /home/mpsuzuki/redhat/BUILD/ft22test/freetype2/src/base/ftrfork.c:182
------------------------------------------------
FreeType: total memory allocations = 12151095
FreeType: maximum memory footprint = 6086760
FreeType: No memory leaks detected!

suzuki toshiya <mpsuzuki>
Project AdministratorIn charge of this item.
Fri 19 May 2006 06:27:50 PM UTC, original submission:

There are two more places I've found where allocated memory isn't freed.

First, in src/base/ftobjs.c, the stream created on line 1525 is closed, but not freed. Here's my fix:

--- freetype-2.2.1/src/base/ftobjs.c 2006-05-01 02:23:26.00 -0700
+++ freetype/src/base/ftobjs.c 2006-05-19 11:22:52.00 -0700
@@ -1531,7 +1531,7 @@

error = IsMacResource( library, stream2, offsets[i],
face_index, aface );
- FT_Stream_Close( stream2 );
+ FT_Stream_Free( stream2, 0 );

FT_TRACE3(( "%s\n", error ? "failed": "successful" ));

Similarly, in src/base/ftrfork.c, the stream created on line 643 is closed but not freed. Here's my fix:

--- freetype-2.2.1/src/base/ftrfork.c 2006-05-02 13:00:44.00 -0700
+++ freetype/src/base/ftrfork.c 2006-05-19 11:25:52.00 -0700
@@ -647,7 +647,7 @@
error = raccess_guess_apple_double( library, stream2, file_name,
&nouse, result_offset );

- FT_Stream_Close( stream2 );
+ FT_Stream_Free( stream2, 0 );

return error;
}

Derek Clegg <derek>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 4 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Fri 19 May 2006 11:18:02 PM UTCmpsuzukiStatusNone=>Fixed
  Open/ClosedOpen=>Closed
  Planned ReleaseNone=>2.3.0
Fri 19 May 2006 09:25:23 PM UTCwlAssigned toNone=>mpsuzuki

Back to the top


Powered by Savane 3.1-cleanup1