iOS app crashing server when uploading files or viewing images

nc14

#1

Nextcloud version: 14.0.4
Operating system and version: Ubuntu 18.04.1 LTS
Apache or nginx version: Apache 2.4.29
PHP version: 7.2.10

The issue you are facing: iOS App causes server to crash when uploading files / or viewing images.

It looks to be an issue where several apache threads are started and the server kills the MariaDB process.

I have had the issue for a while, but I recently limited the number of threads apache would start. The iOS app seems to cause the most issues. Uploading 3-4 photos to a folder will cause my VM to spike the CPU and kill services.

I’ve also started to see the issue when viewing images using iOS client. Getting an error on image.php

Is this the first time you’ve seen this error?: No.

Steps to replicate it:

  1. iOS App - upload several photos from camera roll.

The output of your Nextcloud log in Admin > Logging:

{"reqId":"BBihFlXzLeczvZY88nqm","level":3,"time":"2018-12-06T06:53:59+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"core","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"OC_Image::preciseResize(): Error creating true color image","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}
{"reqId":"C3fTLbOwa7qqtPEbjr03","level":3,"time":"2018-12-06T06:54:46+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"core","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"OC_Image::preciseResize(): Error creating true color image","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}
{"reqId":"7EZ3OqYuorz7UmuOkAiJ","level":3,"time":"2018-12-06T06:54:46+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"core","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"OC_Image::preciseResize(): Error creating true color image","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}
{"reqId":"kl18NWlIzIdY7fcHw8dD","level":3,"time":"2018-12-06T06:54:46+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"core","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"OC_Image::preciseResize(): Error creating true color image","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}
{"reqId":"XANqzEhdAhXPtwSMXWRA","level":3,"time":"2018-12-06T06:56:36+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"core","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"OC_Image::preciseResize(): Error creating true color image","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}
{"reqId":"BBihFlXzLeczvZY88nqm","level":3,"time":"2018-12-06T06:56:36+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"PHP","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"imagedestroy() expects parameter 1 to be resource, boolean given at \/var\/nextcloud\/lib\/private\/legacy\/image.php#884","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}
{"reqId":"7EZ3OqYuorz7UmuOkAiJ","level":3,"time":"2018-12-06T06:56:41+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"PHP","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"imagedestroy() expects parameter 1 to be resource, boolean given at \/var\/nextcloud\/lib\/private\/legacy\/image.php#884","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}
{"reqId":"kl18NWlIzIdY7fcHw8dD","level":3,"time":"2018-12-06T06:56:41+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"PHP","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"imagedestroy() expects parameter 1 to be resource, boolean given at \/var\/nextcloud\/lib\/private\/legacy\/image.php#884","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}
{"reqId":"C3fTLbOwa7qqtPEbjr03","level":3,"time":"2018-12-06T06:56:41+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"PHP","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"imagedestroy() expects parameter 1 to be resource, boolean given at \/var\/nextcloud\/lib\/private\/legacy\/image.php#884","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}
{"reqId":"XANqzEhdAhXPtwSMXWRA","level":3,"time":"2018-12-06T06:56:45+00:00","remoteAddr":"<IP ADD>","user":"<USER>","app":"PHP","method":"GET","url":"\/index.php\/core\/preview.png?file=<FILE>.jpg&x=310&y=552&a=1&mode=cover","message":"imagedestroy() expects parameter 1 to be resource, boolean given at \/var\/nextcloud\/lib\/private\/legacy\/image.php#884","userAgent":"Mozilla\/5.0 (iOS) Nextcloud-iOS\/2.22.5","version":"14.0.4.2"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'STUFF',
  'passwordsalt' => 'STUFF',
  'secret' => 'STUFF',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'my.domain',
  ),
  'datadirectory' => '/media/nc-data',
  'overwrite.cli.url' => 'https://my.domain',
  'dbtype' => 'mysql',
  'version' => '14.0.4.2',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'STUFF',
  'dbpassword' => 'STUFF',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'admin',
  'mail_domain' => 'my.domain',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'email-smtp.us-west-2.amazonaws.com',
  'mail_smtpport' => '587',
  'mail_smtpname' => 'STUFF',
  'mail_smtppassword' => 'STUFF',
  'mail_smtpsecure' => 'tls',
  'installed' => true,
  'maintenance' => false,
  'loglevel' => 2,
  'theme' => '',
  'updater.release.channel' => 'stable',
  'filelocking.enabled' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

<IOS-IP> - - [06/Dec/2018:06:52:58 +0000] "GET /status.php HTTP/1.1" 200 4926 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - - [06/Dec/2018:06:52:58 +0000] "GET /status.php HTTP/1.1" 200 4926 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "GET /index.php/core/preview.png?file=Nextcloud.mp4&x=310&y=552&a=1&mode=cover HTTP/1.1" 404 4709 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "GET /index.php/core/preview.png?file=Nextcloud.mp4&x=310&y=552&a=1&mode=cover HTTP/1.1" 404 4709 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "PROPFIND /remote.php/webdav HTTP/1.1" 207 2301 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "PROPFIND /remote.php/webdav HTTP/1.1" 207 2301 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "POST /ocs/v2.php/apps/notifications/api/v2/push?format=json<REDACTED> HTTP/1.1" 201 2532 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "POST /ocs/v2.php/apps/notifications/api/v2/push?format=json<REDACTED>" 201 2532 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "GET /ocs/v2.php/cloud/user?format=json HTTP/1.1" 200 1914 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "GET /ocs/v2.php/cloud/user?format=json HTTP/1.1" 200 1914 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "GET /ocs/v1.php/cloud/capabilities?format=json HTTP/1.1" 200 3437 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:52:59 +0000] "GET /ocs/v1.php/cloud/capabilities?format=json HTTP/1.1" 200 3437 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "GET /ocs/v2.php/cloud/activity?format=json HTTP/1.1" 200 6186 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "GET /ocs/v2.php/cloud/activity?format=json HTTP/1.1" 200 6186 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "PROPFIND /remote.php/webdav HTTP/1.1" 207 2161 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "PROPFIND /remote.php/webdav HTTP/1.1" 207 2161 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "REPORT /remote.php/dav/files/<IOS-user> HTTP/1.1" 207 2262 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "REPORT /remote.php/dav/files/<IOS-user> HTTP/1.1" 207 2262 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "GET /ocs/v2.php/apps/notifications/api/v2/notifications?format=json HTTP/1.1" 200 1438 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "GET /ocs/v2.php/apps/notifications/api/v2/notifications?format=json HTTP/1.1" 200 1438 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "GET /ocs/v1.php/apps/files_sharing/api/v1/shares HTTP/1.1" 200 1522 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "GET /ocs/v1.php/apps/files_sharing/api/v1/shares HTTP/1.1" 200 1522 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "GET /index.php/core/preview.png?file=PATH/20181110_193156.mp4&x=310&y=552&a=1&mode=cover HTTP/1.1" 404 869 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:53:00 +0000] "GET /index.php/core/preview.png?file=PATH/20181110_193156.mp4&x=310&y=552&a=1&mode=cover HTTP/1.1" 404 869 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - - [06/Dec/2018:06:53:01 +0000] "GET /index.php/avatar/<IOS-user>/128 HTTP/1.1" 201 6308 "-" "Nextcloud/10 CFNetwork/975.0.3 Darwin/18.2.0"
<my.domain>:443 <IOS-IP> - - [06/Dec/2018:06:53:01 +0000] "GET /index.php/avatar/<IOS-user>/128 HTTP/1.1" 201 6308 "-" "Nextcloud/10 CFNetwork/975.0.3 Darwin/18.2.0"
<IOS-IP> - <IOS-user> [06/Dec/2018:06:53:01 +0000] "GET /index.php/core/preview.png?file=Nextcloud.mp4&x=310&y=552&a=1&mode=cover HTTP/1.1" 404 1620 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<my.domain>:443 <IOS-IP> - <IOS-user> [06/Dec/2018:06:53:01 +0000] "GET /index.php/core/preview.png?file=Nextcloud.mp4&x=310&y=552&a=1&mode=cover HTTP/1.1" 404 1620 "-" "Mozilla/5.0 (iOS) Nextcloud-iOS/2.22.5"
<IOS-IP> - - [06/Dec/2018:06:53:03 +0000] "GET /core/img/background.png?v=2 HTTP/1.1" 200 103657 "-" "Nextcloud/10 CFNetwork/975.0.3 Darwin/18.2.0"
<my.domain>:443 <IOS-IP> - - [06/Dec/2018:06:53:03 +0000] "GET /core/img/background.png?v=2 HTTP/1.1" 200 103657 "-" "Nextcloud/10 CFNetwork/975.0.3 Darwin/18.2.0"
120.18.77.44 - - [06/Dec/2018:07:05:27 +0000] "GET / HTTP/1.1" 408 0 "-" "-"
<Route 53 Health Check IP> - - [06/Dec/2018:07:11:10 +0000] "GET /index.php/login HTTP/1.1" 500 3720 "-" "Amazon-Route53-Health-Check-Service (ref ba98892b-e548-459a-bc05-0375aa37b386; report http://amzn.to/1vsZADi)"
<my.domain>:443 <Route 53 Health Check IP> - - [06/Dec/2018:07:11:10 +0000] "GET /index.php/login HTTP/1.1" 500 3720 "-" "Amazon-Route53-Health-Check-Service (ref ba98892b-e548-459a-bc05-0375aa37b386; report http://amzn.to/1vsZADi)"

#2

If your VM start to kill processes, it’s not surprising that you run into errors. Perhaps you find a way to increase the limits for the resources that scripts can have more cputime and/or more memory. The risk of giving more CPU time is that if a couple of people upload pictures, the preview generation might slow down the server for everybody.