Bug 144403

Summary: graphics/php5-gd does not load libpng
Product: Ports & Packages Reporter: kamikaze
Component: Individual Port(s)Assignee: Dirk Meyer <dinoex>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description kamikaze 2010-03-01 22:30:01 UTC
It appears that the PHP5 module /usr/local/lib/php/20060613/gd.so, at least on amd64, does not manage to load libpng.so.5, even though ldd is able to locate it.

This causes attempts to load PNG images to fail:
Warning: imagecreatefrompng() [function.imagecreatefrompng]: gd-png: fatal libpng error: [00][00][00][00]: unknown critical chunk in /usr/home/kamikaze/devel/workspace/realmsofsorrow/nightmare/core/nmTemplate.class.php on line 385
Warning: imagecreatefrompng() [function.imagecreatefrompng]: gd-png error: setjmp returns error condition in /usr/home/kamikaze/devel/workspace/realmsofsorrow/nightmare/core/nmTemplate.class.php on line 385
Warning: imagecreatefrompng() [function.imagecreatefrompng]: './templates/neo/layout/header_stretch.png' is not a valid PNG file in /usr/home/kamikaze/devel/workspace/realmsofsorrow/nightmare/core/nmTemplate.class.php on line 385

I expect that saving doesn't work as well, I didn't test it, though.

I do not know whether other platforms are affected. But 2 more people emailed me, that they have the same issue. Both mod_php and php are affected.

For more detail look at my post on ports@:
http://docs.freebsd.org/cgi/mid.cgi?4B8540AB.9040807

Fix: 

I do not know how to fix this, but I am currently using a very clumsy workaround:

# env LD_PRELOAD=/usr/local/lib/libpng.so.5 /usr/local/etc/rc.d/apache22 restart
How-To-Repeat: Try to use PNG image functions with php5-gd on amd64.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2010-03-01 22:30:25 UTC
Responsible Changed
From-To: freebsd-ports-bugs->ale

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 kamikaze 2010-03-06 08:19:57 UTC
This is an issue with php, not with the apache module:

> php image.php
Warning: imagecreatefrompng(): gd-png:  fatal libpng error: [00][00][00][00]: unknown critical chunk in /usr/home/kamikaze/devel/workspace/realmsofsorrow/image.php on line 68

Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in /usr/home/kamikaze/devel/workspace/realmsofsorrow/image.php on line 68

Warning: imagecreatefrompng(): 'templates/neo/layout/header_stretch.png' is not a valid PNG file in /usr/home/kamikaze/devel/workspace/realmsofsorrow/image.php on line 68

...


The workaround works with direct php calls, too:

> env LD_PRELOAD=libpng.so php image.php
... binary data ...

The binary data amounts to a valid PNG image.
Comment 3 Dirk Meyer freebsd_committer freebsd_triage 2010-04-05 19:31:40 UTC
Responsible Changed
From-To: ale->dinoex

I will take care of it.
Comment 4 Dirk Meyer freebsd_committer freebsd_triage 2010-04-05 19:36:45 UTC
State Changed
From-To: open->closed

Please try again after ports/145247 is fixed.
Comment 5 kamikaze 2010-04-05 21:36:31 UTC
On 05/04/2010 20:37, dinoex@FreeBSD.org wrote:
> Synopsis: graphics/php5-gd does not load libpng
> 
> State-Changed-From-To: open->closed
> State-Changed-By: dinoex
> State-Changed-When: Mon Apr 5 20:36:45 CEST 2010
> State-Changed-Why: 
> Please try again after ports/145247 is fixed.
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=144403

No change, the exact same behaviour as described.


-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Comment 6 Dirk Meyer freebsd_committer freebsd_triage 2010-04-06 02:41:26 UTC
State Changed
From-To: closed->feedback


Please make sure you have updated graphics/php5-gd. 
I have tested it under FreeBSD 8.0 amd64 can can not reproduce your problem. 

I suggest you rebuild apache and php and any other modules you have installed.
Comment 7 kamikaze 2010-04-06 08:02:31 UTC
On 06/04/2010 03:43, dinoex@FreeBSD.org wrote:
> Please make sure you have updated graphics/php5-gd.
> I have tested it under FreeBSD 8.0 amd64 can can not reproduce your problem.

I wish I was in your position in this. ;)

> I suggest you rebuild apache and php and any other modules you have installed.

Apache is not really involved, it was just the first point of
recognition. Everything php has been rebuilt at least twice,
though. And there is a change:

> php image.php | hexdump -C | head -n3
Abort (core dumped)  
> echo $?
134

Obviously not the one I hoped for. The workaround still works:

> env LD_PRELOAD=libpng.so php image.php | hexdump -C | head -n3
00000000  89 50 4e 47 0d 0a 1a 0a  00 00 00 0d 49 48 44 52  |.PNG........IHDR|
00000010  00 00 00 44 00 00 00 a6  08 06 00 00 00 63 9f 29  |...D.........c.)|
00000020  3b 00 00 08 bb 49 44 41  54 78 9c ed 5d cd 92 1c  |;....IDATx..]...|

Regards

-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Comment 8 dirk.meyer 2010-04-06 11:53:38 UTC
Hallo Dominic Fandrey,

> > I suggest you rebuild apache and php and any other modules you have installed.
> 
> Apache is not really involved, it was just the first point of
> recognition. Everything php has been rebuilt at least twice,
> though. And there is a change:
> 
> > php image.php | hexdump -C | head -n3
> Abort (core dumped)  
> > echo $?
> 134

Please provide more info about your apache/php installation.
I aussume some of your extensions is in conflict.

Deinstall all PHP exensions, use only php5-gd and try again.
If the poblem vanish, please install your exensions one by one.


# cat testphp5.php
    $file = '/root/play1.png';
    $a = GetImageSize($file);
    print_r ($a);
    $s = imagecreatefrompng($file); 

# php -f testphp5.php
Array
(
    [0] => 400
    [1] => 400
    [2] => 3
    [3] => width="400" height="400"
    [bits] => 8
    [mime] => image/png
)

# ldd /usr/local/libexec/apache22/libphp5.so 
/usr/local/libexec/apache22/libphp5.so:
        libcrypt.so.5 => /lib/libcrypt.so.5 (0x800882000)
        librt.so.1 => /usr/lib/librt.so.1 (0x800fc7000)
        libm.so.5 => /lib/libm.so.5 (0x8010cc000)
        libxml2.so.5 => /usr/local/lib/libxml2.so.5 (0x8011eb000)
        libz.so.5 => /lib/libz.so.5 (0x801439000)
        libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x80154e000)
        libc.so.7 => /lib/libc.so.7 (0x800647000)

# ldd /usr/local/lib/php/20060613/gd.so 
/usr/local/lib/php/20060613/gd.so:
        libt1.so.5 => /usr/local/lib/libt1.so.5 (0x800c00000)
        libfreetype.so.9 => /usr/local/lib/libfreetype.so.9 (0x800d5b000)
        libX11.so.6 => /usr/local/lib/libX11.so.6 (0x800edc000)
        libXpm.so.4 => /usr/local/lib/libXpm.so.4 (0x80110c000)
        libpng.so.6 => /usr/local/lib/libpng.so.6 (0x80121d000)
        libz.so.5 => /lib/libz.so.5 (0x801343000)
        libjpeg.so.11 => /usr/local/lib/libjpeg.so.11 (0x801458000)
        libc.so.7 => /lib/libc.so.7 (0x800647000)
        libm.so.5 => /lib/libm.so.5 (0x80158d000)
        libxcb.so.2 => /usr/local/lib/libxcb.so.2 (0x8016ac000)
        libXau.so.6 => /usr/local/lib/libXau.so.6 (0x8017c6000)
        libXdmcp.so.6 => /usr/local/lib/libXdmcp.so.6 (0x8018c9000)
        libpthread-stubs.so.0 => /usr/local/lib/libpthread-stubs.so.0 (0x8019ce000)
        librpcsvc.so.5 => /usr/lib/librpcsvc.so.5 (0x801acf000)


kind regards Dirk

- Dirk Meyer, Im Grund 4, 34317 Habichtswald, Germany
- [dirk.meyer@dinoex.sub.org],[dirk.meyer@guug.de],[dinoex@FreeBSD.org]
http://people.freebsd.org/~dinoex/errorlogs/
Comment 9 admin 2010-04-06 12:56:26 UTC
Today I rebuild php from ports

Today in /usr/ports/graphics/php5-gd/files/ add file  "patch-libgd_gd_png.c"

After rebuild I have Abort (core dumped).

My configure: FreeBSD 8.0, PHP 5.2.12_2

What need doing to fix this error?

ImageMagick work perfect with PNG file
Comment 10 eugene 2010-04-06 13:03:04 UTC
# ldd /usr/local/libexec/apache22/libphp5.so
/usr/local/libexec/apache22/libphp5.so:
        libcrypt.so.5 => /lib/libcrypt.so.5 (0x800db7000)
        librt.so.1 => /usr/lib/librt.so.1 (0x800ed0000)
        libm.so.5 => /lib/libm.so.5 (0x800fd5000)
        libxml2.so.5 => /usr/local/lib/libxml2.so.5 (0x8010f4000)
        libz.so.5 => /lib/libz.so.5 (0x80133e000)
        libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x801453000)
        libc.so.7 => /lib/libc.so.7 (0x800648000)

# ldd /usr/local/lib/php/20060613/gd.so
/usr/local/lib/php/20060613/gd.so:
        libt1.so.5 => /usr/local/lib/libt1.so.5 (0x800b5e000)
        libfreetype.so.9 => /usr/local/lib/libfreetype.so.9 (0x800cb8000)
        libX11.so.6 => /usr/local/lib/libX11.so.6 (0x800e39000)
        libXpm.so.4 => /usr/local/lib/libXpm.so.4 (0x801067000)
        libpng.so.6 => /usr/local/lib/libpng.so.6 (0x801178000)
        libz.so.5 => /lib/libz.so.5 (0x80129e000)
        libjpeg.so.11 => /usr/local/lib/libjpeg.so.11 (0x8013b3000)
        libc.so.7 => /lib/libc.so.7 (0x800648000)
        libm.so.5 => /lib/libm.so.5 (0x8014e9000)
        libxcb.so.2 => /usr/local/lib/libxcb.so.2 (0x801608000)
        libXau.so.6 => /usr/local/lib/libXau.so.6 (0x801722000)
        libXdmcp.so.6 => /usr/local/lib/libXdmcp.so.6 (0x801825000)
        libpthread-stubs.so.0 => /usr/local/lib/libpthread-stubs.so.0
(0x80192a000)
        librpcsvc.so.5 => /usr/lib/librpcsvc.so.5 (0x801a2b000)

After run # cat gd.php
<?php
    $file = '/root/play1.png';

    $a = GetImageSize($file);

    print_r ($a);

    $s = imagecreatefrompng($file);
?>

#php gd.php
Abort (core dumped)

Today install all patch and update!

---
ó Õ×ÁÖÅÎÉÅÍ,
ëÒÉ×ÏÒÕÞËÏ å×ÇÅÎÉÊ

em@il: eugene@krivoruchko.info
icq: 244064173
phone: +7 (926) 255-84-34
msn: flex_idknet@msn.com
skype: flexidk
www: http://flipflip.ru/
Comment 11 kamikaze 2010-04-06 18:31:11 UTC
On 06/04/2010 12:53, Dirk Meyer wrote:
> Hallo Dominic Fandrey,
> 
>>> I suggest you rebuild apache and php and any other modules you have installed.
>>
>> Apache is not really involved, it was just the first point of
>> recognition. Everything php has been rebuilt at least twice,
>> though. And there is a change:
>>
>>> php image.php | hexdump -C | head -n3
>> Abort (core dumped)  
>>> echo $?
>> 134
> 
> Please provide more info about your apache/php installation.
> I aussume some of your extensions is in conflict.

# pkg_info -Ex php
php5-5.2.12_2
php5-gd-5.2.12_2

> Deinstall all PHP exensions, use only php5-gd and try again.
> If the poblem vanish, please install your exensions one by one.

Done, no change.

> # cat testphp5.php
>     $file = '/root/play1.png';
>     $a = GetImageSize($file);
>     print_r ($a);
>     $s = imagecreatefrompng($file); 
> 
> # php -f testphp5.php
> Array
> (
>     [0] => 400
>     [1] => 400
>     [2] => 3
>     [3] => width="400" height="400"
>     [bits] => 8
>     [mime] => image/png
> )

# php -f testphp5.php
Array
(
    [0] => 2560
    [1] => 1600
    [2] => 3
    [3] => width="2560" height="1600"
    [bits] => 8
    [mime] => image/png
)
Abort (core dumped)
# echo $?
134


# env LD_PRELOAD=libpng.so php -f testphp5.php
Array
(
    [0] => 2560
    [1] => 1600
    [2] => 3
    [3] => width="2560" height="1600"
    [bits] => 8
    [mime] => image/png
)

Note the lack of a core dump.

> # ldd /usr/local/lib/php/20060613/gd.so 

/usr/local/lib/php/20060613/gd.so:
	libt1.so.5 => /usr/local/lib/libt1.so.5 (0x800c00000)
	libfreetype.so.9 => /usr/local/lib/libfreetype.so.9 (0x800d58000)
	libX11.so.6 => /usr/local/lib/libX11.so.6 (0x800ed5000)
	libXpm.so.4 => /usr/local/lib/libXpm.so.4 (0x8010fd000)
	libpng.so.6 => /usr/local/lib/libpng.so.6 (0x80120d000)
	libz.so.5 => /lib/libz.so.5 (0x801332000)
	libjpeg.so.11 => /usr/local/lib/libjpeg.so.11 (0x801446000)
	libc.so.7 => /lib/libc.so.7 (0x800645000)
	libm.so.5 => /lib/libm.so.5 (0x801582000)
	libxcb.so.2 => /usr/local/lib/libxcb.so.2 (0x8016a1000)
	libXau.so.6 => /usr/local/lib/libXau.so.6 (0x8017ba000)
	libXdmcp.so.6 => /usr/local/lib/libXdmcp.so.6 (0x8018bc000)
	librpcsvc.so.5 => /usr/lib/librpcsvc.so.5 (0x8019c1000)
	libpthread-stubs.so.0 => /usr/local/lib/libpthread-stubs.so.0 (0x801ac9000)

Regards

-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Comment 12 kamikaze 2010-04-10 08:16:38 UTC
The problem is gone with the switch to the php-5.3 branch.

Thank you all for your time and efforts!
Comment 13 Dirk Meyer freebsd_committer freebsd_triage 2010-04-10 09:42:01 UTC
State Changed
From-To: feedback->closed

problem solved