Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imagick does not limit its memory usage, can crash php-fpm processes #67

Open
OscarBarrett opened this issue Nov 16, 2022 · 3 comments
Open
Labels
bug Something isn't working

Comments

@OscarBarrett
Copy link

Description

e.g. For a container with a 768M memory limit, uploading a 6MB GIF to the Assets section will cause the php-fpm process to exhaust all available memory then be killed.

This can be limited by setting ENV MAGICK_MEMORY_LIMIT 200M in the image (or some other sane memory limit for the use case).

Would like to suggest that this gets baked in to the image.

Steps to reproduce

  1. Upload a large image to the Asset library
  2. See 502 in the network tab, logs
[16-Nov-2022 07:27:43] WARNING: [pool www] child 30 exited on signal 9 (SIGKILL) after 161.276694 seconds from start
[16-Nov-2022 07:27:43] NOTICE: [pool www] child 35 started
2022/11/16 07:27:43 [error] 19#19: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.24.0.1, server: _, request: "POST /index.php?p=admin/actions/assets/upload HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost", referrer: "http://localhost/admin/assets/assets"

This happens after just a few seconds.

Additional info

  • Craft version: 3.7.59
  • PHP version: 7.4
  • Database driver & version: MySQL 8
  • Plugins & versions: N/A
  • Image: craftcms/nginx:8.0
@OscarBarrett OscarBarrett added the bug Something isn't working label Nov 16, 2022
@BAM-Dennis
Copy link

We are facing the same issue with the 8.1 image. exact same definition and error as @OscarBarrett

Setting the ENV var as suggested helped.

i think this issue is only related to you, if you are limiting a containers resources

@Numkil
Copy link

Numkil commented Feb 21, 2024

What a lifesaver this issue is <3 Got stuck for a few hours trying to debug this exact issue until i found this ticket.

I think baking this into the container would be a great benefit to a lot of users. Maybe configurable like the PHP memory limit and such already is.

@jawys
Copy link
Contributor

jawys commented Feb 21, 2024

Actually you do not need to bake it necessarily.

Just set or pass MAGICK_MEMORY_LIMIT with a sane value when starting the container or compose service etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants