GD toolkit & operations should catch \Throwable to fail gracefully in case of errors

Created on 8 October 2015, over 9 years ago
Updated 7 February 2023, almost 2 years ago

Problem/Motivation

GD toolkit and operations fail with WSOD in case of errors or exceptions.

Proposed resolution

Catch the \Throwable error and log its description in the image logger, fail gracefully.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None

Original issue

Executing something like this

      $test = \Drupal::service('image.factory')->get(NULL, 'gd');
      $test->createNew(20000, 20000);

leads to a fatal error

PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 80000 bytes) in /[...]/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php on line 94

and WSOD.

This is because GD imagexxx functions do not return gracefully in case of memory allocation failures.

Proposed resolution (no longer valid, kept for history reasons)

Take cues from the preliminary memory availability check done in the color module, and from this comment on PHP site, and introduce a memory checking method that can be called on load, create_new, and rotate operations before invoking imagexxx functions.

๐Ÿ› Bug report
Status

Fixed

Version

10.1 โœจ

Component
Image systemย  โ†’

Last updated 1 day ago

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024