php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36418 Graphics errors on multiple processes
Submitted: 2006-02-16 15:31 UTC Modified: 2006-02-20 15:20 UTC
From: jraben at alstermedia dot de Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 5.1.2 OS: Win XP
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: jraben at alstermedia dot de
New email:
PHP Version: OS:

 

 [2006-02-16 15:31 UTC] jraben at alstermedia dot de
Description:
------------
It's a script that joins a background .gif picture with transparent png 24-bit pictures to a thumb jpg. It actually no the complete script. $bfile is always the same. $file and $target may vary.

Some files have corrupted backgrounds, if the script is started in multiple instances at the same time. Seems to be a memory allocation bug.

Reproduce code:
---------------
$img = @imagecreatefromgif("$bfile");
$imgobj = @imagecreatefrompng("$file");
imagealphablending ( $imgobj, true );
$width = imagesx($imgobj);
$height = imagesy($imgobj);
$imgnew = imagecreatetruecolor($width, $height);
imagecopyresampled($imgnew,$img,0,0,$x,$y,$width,$height,$width,$height);
imagecopyresampled($imgnew,$imgobj,0,0,0,0,$width,$height,$width,$height);
imagejpeg($imgnew, $target, 90);


Expected result:
----------------
Not currupted pictures as .jpg with $bfile gif as background and $file .png as foreground.

Actual result:
--------------
Some files have corrupted backgrounds, if this script is started in multiple instances at the same time. Seems to be a memory allocation bug or something with loading the same picture multiple times at the same time.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-16 16:10 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2006-02-16 16:19 UTC] pajoye@php.net
Please provide a set of source images and a valid script to reproduce the problems. That means a working script, valid filenames, source images, etc.

 [2006-02-16 17:10 UTC] jraben at alstermedia dot de
Ok! Try this script:

http://www.alstermedia.de/phpbug.zip

Give 777 to out and script. For for finish and check all pics.  Almost on every run there are 3-4 pics with corrupted background. If you do not see a bug try to refresh serveral times.

I included a corrupted pic called "1.jpg".
 [2006-02-16 17:13 UTC] jraben at alstermedia dot de
btw I also tried the recent snapshot of php 5. Same bug.
 [2006-02-16 17:21 UTC] pajoye@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.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You should consider to check concurrent accesses before writing the images.
 [2006-02-20 15:20 UTC] jraben at alstermedia dot de
But why then the bug only affects the background gif, not the png foreground? If you would be right, the programming error or missed code should also affect the png part. Seems to be a bug within gif code to me...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Sep 20 22:00:01 2025 UTC