- Issue created by @mondrake
- 🇮🇹Italy mondrake 🇮🇹
@andypost not really, no. In 🐛 GD toolkit & operations should catch \Throwable to fail gracefully in case of errors Fixed I was proposing to pre-calculate the memory required before executing the operation and fail in case it would exceed the available memory reported by PHP, but that proposal did not get through, https://www.drupal.org/project/drupal/issues/2583041#comment-14725453 🐛 GD toolkit & operations should catch \Throwable to fail gracefully in case of errors Fixed .
Actually, when 🐛 GD toolkit & operations should catch \Throwable to fail gracefully in case of errors Fixed was opened, we were in PHP 5 and the failure was quite evident. We're in PHP8land now and it seems this is occurring less, but still sometimes it does. #2583041-124: GD toolkit & operations should catch \Throwable to fail gracefully in case of errors → is a case when the error occurred in a PostgreSql based test runner, when all other tests run fine. So it maybe something related to PHP build, but that will be hard to find.
So, to start right with, we probably need new steps to reproduce.
- @mondrake opened merge request.
- Status changed to Needs work
over 1 year ago 4:07pm 7 February 2023 - 🇮🇹Italy mondrake 🇮🇹
No, PHP8.1 with pgsql fails. What has the db to do with GD failure who knows.
- 🇮🇹Italy mondrake 🇮🇹
Uhm. pgsql fails in StatementWrapper... not in GD... could be this has to do with test's tear down and db cleanup. It would interesting to check this combined with 🐛 Implement statement classes using \Iterator to fix memory usage regression and prevent rewinding Fixed .
- 🇮🇹Italy mondrake 🇮🇹
The last commit in the MR now shows the failure.
Of the two test cases,
(1)
$this->assertFalse($image->createNew(2000000, 2000000));
is actually false because createNew fails and fires a warning like
imagecreatetruecolor(): product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
while
(2) the second test (limiting the memory available for PHP and trying to create an image that goes beyond that), fails with the memory errorPHP Fatal error: Allowed memory size of 13631488 bytes exhausted (tried to allocate 61440 bytes) in /var/www/html/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php on line 89 Fatal error: Allowed memory size of 13631488 bytes exhausted (tried to allocate 61440 bytes) in /var/www/html/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php on line 89
Now, while I can reproduce (1) also locally, I can't reproduce (2).
I suspect that is because in my testing environment I have a PHP built with external GD library on 2.3.3, whereas the one used by DrupalCI bots uses the embedded GD library that is equivalent to the 2.1 version (IIRC). Given this https://github.com/libgd/libgd/issues/122 happened in 2.3, it could be that this explains the different behaviour.
- 🇺🇸United States karolus
From the linked libgd issue, it appears this problem could be solved by adding 64-bit support, unless I'm totally misinterpreting things. It's something I've come across a few times, on images that don't appear at first to be that large.