php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24844 Gif read support not thread safe
Submitted: 2003-07-28 09:45 UTC Modified: 2003-07-30 17:21 UTC
From: e9925248 at stud4 dot tuwien dot ac dot at Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.3RC2-dev 5.0.0b2 OS: Windows 2000
Private report: No CVE-ID: None
 [2003-07-28 09:45 UTC] e9925248 at stud4 dot tuwien dot ac dot at
Description:
------------
If mod_php4 (precompiled from the web page), with php_gd2.dll extension loaded, is used in Apache/1.3.27 on Windows 2000, createimagefromgif returns black images or only parts of the image, if some pages call it at the same time.

For example:
<?php
header ("Content-type: image/jpeg");
$im="image.gif";
$im1=imagecreatefromgif($im);
imagejpeg($im1);
?>
image.gif can be any gif, some KBs big.

Run in many terminal then something like
while /bin/true; do wget "http://server/skript.php"; done

only a part of the saved images will be ok. If only one images is fetched at a time, all images are ok.

If the skript is used by many users, web browsers also show black images or parts of the image.

I think, the error is in the bundled libgd, in gd_gif_in.c. There global and static variables are used to read the gif, which all threads seem to share. Removing them and storing them in a per Request state, seems to solve the problem for me.

An example patch, which works for me, is at: http://stud4.tuwien.ac.at/~e9925248/php/gd-gif.diff

Martin K?gler
e9925248@stud4.tuwien.ac.at


Reproduce code:
---------------
<?php
header ("Content-type: image/jpeg");
$im="image.gif";
$im1=imagecreatefromgif($im);
imagejpeg($im1);
?>

Expected result:
----------------
The gif-image as jpeg

Actual result:
--------------
If some users use the script at the same time, the image has black parts.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-28 09:48 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

GD distributed with PHP does not support GIFs due to UNISYS patents on the compression format used by GIF.
 [2003-07-28 13:07 UTC] iliaa@php.net
Actually my inital comment was not entirely correct, we do support 'read' functionality for gif, but no write support. However, GD extension itself is not thread-safe due to other libraries that is it using.
 [2003-07-30 17:21 UTC] sniper@php.net
Not PHP bug.

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Feb 17 04:00:02 2026 UTC