|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71626 gmagick extension works only twice via PHP FPM
Submitted: 2016-02-18 16:26 UTC Modified: 2016-02-19 12:14 UTC
From: maximilian dot bloch at gmail dot com Assigned: danack (profile)
Status: Closed Package: gmagick (PECL)
PHP Version: 5.6.18 OS: Ubuntu 15.10
Private report: No CVE-ID: None
 [2016-02-18 16:26 UTC] maximilian dot bloch at gmail dot com
The below code fails via nginx+php-fpm after the second try. It works the first two tries only. If I restart|reload php-fpm, the script works again, exactly two consecutive times, then it fails again.

I am running gmagick-1.1.7RC3

I have tried tweaking some php-fpm settings with no effect.

I have tried several fonts with the same results.

php-cli work just fine.

I disabled the imagick extension with the same results, so I do not see a conflict here.

Thanks for your help.

Test script:
$image = new Gmagick();
$fontDraw = new GmagickDraw();
$fontMetrics = $image->queryFontMetrics($fontDraw, 'g');
// EOF

Expected result:
Array ( [characterWidth] => 72 [characterHeight] => 72 [ascender] => 71 [descender] => -32 [textWidth] => 36 [textHeight] => 103 [maximumHorizontalAdvance] => 61 ) 

Actual result:
Fatal error: Uncaught exception 'GmagickException' with message 'Wand contains no images `%.1024s (MagickWand-2)' in test.php:6 Stack trace: #0 test.php(6): Gmagick->queryfontmetrics(Object(GmagickDraw), 'g') #1 {main} thrown in test.php on line 6


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-19 02:03 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: danack
 [2016-02-19 02:03 UTC]
I can reproduce inside a single script with the code below.

There is a very good chance that the bug is that it works at all - looking at the code, queryFontMetrics is not meant to work if there are no images associated with the Gmagick object. i.e. it is likely the bug fix will to make it consistently fail for this code.

for ($i=0; $i<5; $i++) {
	$image = new Gmagick();
	$fontDraw = new GmagickDraw();
	$fontMetrics = $image->queryFontMetrics($fontDraw, 'g');
 [2016-02-19 12:14 UTC]
-Status: Verified +Status: Closed
 [2016-02-19 12:14 UTC]
This should be fixed in the next release of Gmagick.

As a workaround, you should be able to call it safely on any Gmagick object that contains an image. So either one of the images you're actually processing or a built-in one like "$gmagick = new \Gmagick("magick:logo");"
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 21:01:31 2024 UTC