Bug #70315 [Com]: imagecreatefromstring() returns 500 Server Error but page full renderized

From: Date: Mon, 04 Jul 2016 14:17:38 +0000
Subject: Bug #70315 [Com]: imagecreatefromstring() returns 500 Server Error but page full renderized
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202046@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70315&edit=1

 ID:                 70315
 Comment by:         razzari at gmail dot com
 Reported by:        patriciotarantino at gmail dot com
 Summary:            imagecreatefromstring() returns 500 Server Error but
                     page full renderized
 Status:             Assigned
 Type:               Bug
 Package:            GD related
 Operating System:   Ubuntu
 PHP Version:        5.6.12
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

I can also repro with Nginx and FPM/FastCGI. 
PHP Version 5.5.9-1ubuntu4.17.
GD Version 2.1.1-dev.


Previous Comments:
------------------------------------------------------------------------
[2016-07-04 13:32:59] razzari at gmail dot com

This was mod_php (libapache2-mod-php5.6).

------------------------------------------------------------------------
[2016-07-04 11:25:43] cmb@php.net

> mod_apache

Of course I meant mod_php!

------------------------------------------------------------------------
[2016-07-04 11:25:02] cmb@php.net

@razzari Thanks for the detailed explanation. I'll try to
reproduce with your environement. Do you use FPM or mod_apache?

------------------------------------------------------------------------
[2016-07-03 22:27:00] razzari at gmail dot com

Here's the logs as text (Sorry, I had included them in the screenshot in the prev comment).

PHP Unknown error:  imagecreatefromstring(): gd-png: fatal libpng error: IHDR: CRC error\n in
Unknown on line 0
PHP Parse error:  imagecreatefromstring(): gd-png error: setjmp returns error condition 1\n in
/var/www/test.php on line 6
PHP Warning:  imagecreatefromstring(): Passed data is not in 'PNG' format in
/var/www/test.php on line 6
PHP Warning:  imagecreatefromstring(): Couldn't create GD Image Stream out of Data in
/var/www/test.php on line 6

I can repro this consistently.

Please let me know if I can provide further info/tests. 

This is a barebones install in Ubuntu 12.04, Apache/2.4.2, PHP 5.6.23-2+deb.sury.org~precise+1.
I've just installed this in a Vagrant box for testing. (That is, this isn't a prod server
with weird configs or a dev server wit cruft that's piled up over the years).

------------------------------------------------------------------------
[2016-07-03 22:13:59] razzari at gmail dot com

This is still happening on PHP Version 5.6.23.

Screenshot: https://i.imgur.com/p680DMk.png

Note that BOTH the test text AND the 500 status code are displayed. 

As noted by the OP, this only happens if display_errors is off. 

If I enable errors, things work as expected. The error is displayed, and the page returns with a 200
OK status.  Screenshot: https://i.imgur.com/8jyuiot.png

Compare this with standard platform behavior, where an error with display_errors off will produce a
500 error AND a blank page. It is NOT displaying the test text. Screenshot https://i.imgur.com/VCBOmun.png and sample code:

<?php
# This works as expected.
ini_set("display_errors", 0);
trigger_error("Some error.", E_USER_ERROR);
echo "This should not render";
?>

So to recap, expected behavior is:
Display errors OFF: Blank page, 500 status code. 
Display errors ON: Visible error text, some page content that worked, and 200 status code. 

Actual result in this situation is:
Display errors OFF: Some page content that worked, 500 status code.

Why this is a serious issue: site owners and visitors will believe the site is working OK. But
Google will believe it's utterly broken and won't bother crawling it.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=70315


--
Edit this bug report at https://bugs.php.net/bug.php?id=70315&edit=1


Thread (17 messages)

« previous php.bugs (#202046) next »