php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32775 PHP crashes with a segmentation fault on GD2 function
Submitted: 2005-04-20 11:46 UTC Modified: 2005-04-20 17:08 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dirk dot msc at gmx dot de Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.0.4 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dirk dot msc at gmx dot de
New email:
PHP Version: OS:

 

 [2005-04-20 11:46 UTC] dirk dot msc at gmx dot de
Description:
------------
The following script produces a segmentation fault on Linux whereas it works perfectly on Windows.
You can find the image here: http://www.hdx4.com/neu/images/buttons/templates/border_top.gif

Please download it as the URL may change.

Reproduce code:
---------------
  $img = @imagecreatetruecolor (100, 21) or die ("Cannot Initialize new GD image stream");
  $col_white=imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
  imagefill($img, 0,0, $col_white);

  $top=@imagecreatefromgif("border_top.gif");
//  $top=@imagecreatefrompng("default.png");  // if I use this one it works

  if ($top) {
    imagesettile($img, $top);
    imagefill($img, 0,0, IMG_COLOR_TILED);
  }
  
  header ("Content-type: image/png");
  imagepng($img);
  imagedestroy($img);
  imagedestroy($top);

Expected result:
----------------
Anything, but not a crash.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-20 11:49 UTC] derick@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
 [2005-04-20 16:46 UTC] dirk dot msc at gmx dot de
Note: This does not happen with the Windows version of PHP5.

Backtracking the core dump with gdb indicates a crash in the gdImageFill () function.
 [2005-04-20 16:51 UTC] derick@php.net
Please provide that backtrace as we requested...
 [2005-04-20 17:05 UTC] dirk dot msc at gmx dot de
Backtracing outputs:

#0  0x400a2755 in gdImageSetPixel ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#1  0x400a2257 in gdImageSetPixel ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#2  0x400a3e3c in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#3  0x400a3f54 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#4  0x400a3ff8 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#5  0x400a3f54 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#6  0x400a3ff8 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#7  0x400a3f54 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#8  0x400a3ff8 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#9  0x400a3f54 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#10 0x400a3ff8 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#11 0x400a3f54 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#12 0x400a3ff8 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#13 0x400a3f54 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#14 0x400a3ff8 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
#15 0x400a3f54 in gdImageFill ()
   from /usr/local/gd-2.0.15-gif/lib/libgd.so.2
...

This goes on up to about 16,000.
 [2005-04-20 17:08 UTC] sniper@php.net
It's pretty likely that this is a GD bug which we have fixed in the bundled version of ours. The latest GD release is 2.0.33 btw..

Either update the external GD lib or use the bundled one.
(--with-gd without path)

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Nov 22 01:00:02 2025 UTC