From:             [EMAIL PROTECTED]
Operating system: Linux 2.2.19
PHP version:      4.3.0RC1
PHP Bug Type:     GD related
Bug description:  With builtin GD, memory leak and segfault

I have a PHP script for outputting a PNG image. It uses the following
functions:
  ImageCreateFromPNG
  ImageColorClosest
  ImageTTFText
  ImageTTFBBox
  ImageLine
  ImagePNG
  ImageDestroy

This worked correctly with PHP 4.0.6 , GD 1.8.4, FreeType 1.3.1. (At the
time I first installed PHP4, these were the latest versions of GD and
FreeType that behaved properly). 

When I upgraded to PHP 4.3.0RC1, with builtin GD, executing the same
script produced memory leak errors in the Apache log:

/usr/local/src/php-4.3.0RC1/ext/gd/libgd/gdhelpers.c(89) :  Freeing
0x082B9CE4 (8 bytes), script=/u/www/paygate/cheque-image.php
Last leak repeated 270 times
/usr/local/src/php-4.3.0RC1/ext/gd/libgd/gdhelpers.c(89) :  Freeing
0x082BDDA4 (8 bytes), script=/u/www/paygate/cheque-image.php
[Mon Nov 18 12:48:04 2002] [notice] child pid 10950 exit signal
Segmentation fault (11)
/usr/local/src/php-4.3.0RC1/ext/gd/libgd/gdhelpers.c(89) :  Freeing
0x082B8B84 (8 bytes), script=/u/www/paygate/cheque-image.php
Last leak repeated 264 times

Sometimes the image would still display correctly anyway, and sometimes
there would be no output (presumably corresponding to those times that
Apache segfaulted, although I did not check this explicitly).

I found that I could correct the problem by not using the builtin GD. This
required two steps:
  -- modify my ./configure command to use --with-gd=/path/to/gd instead of
--with-gd
  -- modify php_config.h to say HAVE_GD_GD2 0  (in 2 places), ./configure
did not pick up automatically that my installed GD was 1.x 

After rebuilding with these GD settings the image was generated correctly
with no memory leaks and no segfaults.

I guess therefore that there is something wrong with the builtin GD code.

Here is my ./configure line (that generates the buggy version):

./configure --with-mcrypt --with-mhash --with-mysql=../../mysql --with-gd
--enable-versioning --with-ttf --enable-shared
--enable-freetype-4bit-antialias-hack --with-informix --with-bz2
--with-gmp --with-zlib --enable-sockets --with-config-dir=/usr/local/etc
--enable-debug --with-png-dir=/usr/local --with-jpeg-dir=/usr/local
--without-pear --with-apxs

When using "--with-gd", phpinfo() displays "GD Version" as "bundled (2.0
compatible)" and "GIF Support" as "enabled". When using
"--with-gd=/path/to/gd", phpinfo() displays "GD Version" as "1.6.2 or
higher" and does not display the "GIF Support" line. All other GD fields
stay the same (ie. "enabled", except for "FreeType Linkage" which is "with
TTF library").

Thanks,
Matt.

-- 
Edit bug report at http://bugs.php.net/?id=20470&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=20470&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=20470&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=20470&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=20470&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=20470&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=20470&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=20470&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=20470&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=20470&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=20470&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20470&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=20470&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=20470&r=isapi

Reply via email to