php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67108 imageCreateFromJpeg (or any other function) must not terminate script silently
Submitted: 2014-04-22 06:44 UTC Modified: 2014-04-22 07:31 UTC
From: romtek at gmail dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.5.11 OS: Windows, Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: romtek at gmail dot com
New email:
PHP Version: OS:

 

 [2014-04-22 06:44 UTC] romtek at gmail dot com
Description:
------------
The notorious situation: calling imageCreateFromJpeg() terminates the calling script SILENTLY when it can't allocate enough memory, leaving no way to gracefully handle the situation. Even using set_error_handler() is useless in this case. 

This problem is widely known and talked about for a long time. While terminating a script silently is OK for a project in Programming 101 course, it unacceptable for a business website.

Please make it so this function (and all other functions in PHP) allow for graceful handling of errors. This could be throwing an exception or returning an error code.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-22 06:54 UTC] pajoye@php.net
-Status: Open +Status: Not a bug
 [2014-04-22 06:54 UTC] pajoye@php.net
It is by design. Out of memory (be with memory limit or system) should not allow any other operation as it can't end well anyway. Nothing can be allocated anymore, so how would we manage errors (msg, stack, etc)?

If you use a the memory limite and need more for specific areas, you can change it via php.ini (and the likes).
 [2014-04-22 07:31 UTC] romtek at gmail dot com
OK, how about this: when imageCreateFromJpeg() reaches the memory limit, it should release all memory it had been able to allocate. This will probably create enough memory for handling the error. The VM should keep enough memory in its pool to let scripts handle such errors gracefully.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 04:01:28 2024 UTC