php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18303 PHP crashes when ImagePNG() is used
Submitted: 2002-07-12 06:53 UTC Modified: 2002-08-19 09:41 UTC
From: thx dot 79 at schweiz dot org Assigned:
Status: Closed Package: GD related
PHP Version: 4.2.1 OS: Linux (Kernel 2.4.4-4GB)
Private report: No CVE-ID: None
 [2002-07-12 06:53 UTC] thx dot 79 at schweiz dot org
This report is a follow up for http://bugs.php.net/bug.php?id=17659 which was set to Status 'Bogus' because the original reporter didn't provide the requested feeback.

So once more: PHP crashes with 'Segmentation Fault' when I use ImagePNG().

My System:
* SuSE Linux 7.2 (Kernel 2.4.4-4GB)
* Apache 1.3.24
* PHP-4.3.0-dev -> 'php4-200207111200', which was 'php4-latest' last night (July 11th 2002).
=> But it's the same with PHP-4.2.1 & PHP-4.2.2-dev
* GD 2.0.1
* zlib-1.1.4
* libpng-1.2.4

The Script:

8<--------------------------------------------------------
<?php

$dstWidth   = 100 ;
$dstHeight  = 100 ;

$dstImg = ImageCreate( $dstWidth, $dstHeight );

$bgCol  = ImageColorAllocate( $dstImg,   0,   0,   0 );
$col    = ImageColorAllocate( $dstImg, 255, 255,   0 );

ImageString( $dstImg, 4, 5, 5, "TEST" ,$col );

header( "Content-type: image/png" );
ImagePNG( $dstImg );
ImagePNG( $dstImg, "test.png" );

ImageDestroy( $dstImg );

?>
8<--------------------------------------------------------

The Backtrace:

8<--------------------------------------------------------
(gdb) run -X
Starting program: /usr/local/apache/bin/httpd -X

Program received signal SIGSEGV, Segmentation fault.
0xa01 in ?? ()
(gdb) bt
#0  0xa01 in ?? ()
#1  0x405039d9 in png_create_write_struct_2 () from /usr/local/lib/libpng12.so.0
#2  0x40504e42 in png_create_write_struct () from /usr/local/lib/libpng12.so.0
#3  0x4058e13e in gdImagePngCtx () from /usr/local/lib/libgd.so
#4  0x40249360 in _php_image_output_ctx (ht=1, return_value=0x811aaf4, this_ptr=0x0, return_value_used=0, image_type=2,
    tn=0x403dc36d "PNG", func_p=0x4058e0d0 <gdImagePngCtx>) at /usr/local/src/php4-200207111200/ext/gd/gd_ctx.c:94
#5  0x4024e27f in zif_imagepng (ht=1, return_value=0x811aaf4, this_ptr=0x0, return_value_used=0)
    at /usr/local/src/php4-200207111200/ext/gd/gd.c:1432
#6  0x403c0a67 in execute (op_array=0x81158a4) at /usr/local/src/php4-200207111200/Zend/zend_execute.c:1587
#7  0x403adb84 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/local/src/php4-200207111200/Zend/zend.c:810
#8  0x403765d1 in php_execute_script (primary_file=0xbffff458) at /usr/local/src/php4-200207111200/main/main.c:1388
#9  0x403c5d90 in apache_php_module_main (r=0x810a9f4, display_source_mode=0)
    at /usr/local/src/php4-200207111200/sapi/apache/sapi_apache.c:55
#10 0x403c6d40 in send_php (r=0x810a9f4, display_source_mode=0, filename=0x810b474 "/home/www/thx/htdocs/image-png.php")
    at /usr/local/src/php4-200207111200/sapi/apache/mod_php4.c:550
#11 0x403c6dc3 in send_parsed_php (r=0x810a9f4) at /usr/local/src/php4-200207111200/sapi/apache/mod_php4.c:565
#12 0x8054799 in ap_invoke_handler ()
#13 0x806a96f in process_request_internal ()
#14 0x806a9e2 in ap_process_request ()
#15 0x8061336 in child_main ()
#16 0x80614f5 in make_child ()
#17 0x8061676 in startup_children ()
#18 0x8061d1d in standalone_main ()
#19 0x806257c in main ()
#20 0x400b2c6f in __libc_start_main () from /lib/libc.so.6
8<--------------------------------------------------------

If you need anything else, I'd be delighted to help.

Bye, Thomas

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-12 07:00 UTC] sander@php.net
I'm using libpng 1.0.12 and I don't have any problems. As Jani (sniper) said on the orginal bugreport, libpng 1.2.x is reported to work badly with libgd. You might try downgrading libpng to 1.0.x. If the problem goes away, then it's probably not a bug in PHP. 
 [2002-07-12 08:06 UTC] sniper@php.net
And make sure you really have compiled both PHP and GD with SAME libraries (libpng, zlib..etc.)

 [2002-07-22 21:29 UTC] thx dot 79 at schweiz dot org
Ok, you were right. Downgrading to libpng-1.0.14 was the right thing to do.
But I still think this is a little bit odd and the problem still seems to be somehow PHP-related, because if I compile GD with libpng-1.2.4 (which crashes in PHP) and then run 'make test', all PNG-Images are generated without _any_ problem at all!

And, aren't there any functionalities missing, when I just have the older version of libpng??

Bye, Thomas
 [2002-07-22 21:32 UTC] sniper@php.net
I'm unable to get PHP to crash when using libpng 1.2.0. 
You propably had a mixup with the libs. Remove ALL existing
libpng* files and recompile libgd using 1.2.x and remember
to point PHP configure to the SAME libs with --with-png-dir

 [2002-07-23 08:44 UTC] thx dot 79 at schweiz dot org
Ok, I deleted /usr/local completely and compiled everything from scratch....and it worked. So it must have been something with the libs or so.

Thanks and bye,
Thomas
 [2002-08-19 09:41 UTC] thx dot 79 at schweiz dot org
Ok, final notes on this one:
The problem wasn't libpng, zlib or jpeg-6b, it was the PDF-Library!! See also Bug 16841 for a similar case. So before you try to recompile libpng and the other stuff, try (re)compiling the newest version of pdflib...

It took me quite a while to figure this all out, so I hope this helps anybody else to save some time.

Bye, Thomas
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 00:01:29 2024 UTC