Git LFS fails with large images

Observed Behavior

When trying to push large image files to a Phabricator-managed git LFS repository, Phabricator fails with a fatal error.

Git client output:

$ git lfs push origin master
Git LFS: (0 of 4 files, 75 skipped) 4.00 KB / 29.37 MB, 1.02 MB skipped
Fatal error: Server error: https://phabricator.example.com/diffusion/R/repo.git/info/lfs/upload/d70bb7c9f115e9aeb922aea6185f07d88547ead1013fa26a759db6dd1bec8c1a
Fatal error: Server error: https://phabricator.example.com/diffusion/R/repo.git/info/lfs/upload/406a23760569dcd51392122d0832e118416816612dc16be38eb9348270b2ecc6
Fatal error: Server error: https://phabricator.example.com/diffusion/R/repo.git/info/lfs/upload/787e360064b98c6a3894feed8941c3ab85c8fbfdbbec3a1ee99a0a6efcd18cfe
Fatal error: Server error: https://phabricator.example.com/diffusion/R/repo.git/info/lfs/upload/8bb210ac3aa2b3db758482db4068f9822efb74143cb90386864245e90e7b1090

Server error log:

[Fri Oct 20 09:33:08.054983 2017] [:error] [pid 20017] [client IP:51990] PHP Fatal error:  imagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n in /var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php on line 1059
[Fri Oct 20 09:33:08.055191 2017] [:error] [pid 20017] [client IP:51990] >>> UNRECOVERABLE FATAL ERROR <<<\n\nimagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n\n\n/var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php:1059\n\n\n\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb \xef\xb8\xb5 \xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf \xef\xb8\xb5 \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb
[Fri Oct 20 09:33:08.883316 2017] [:error] [pid 19957] [client IP:51989] PHP Fatal error:  imagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n in /var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php on line 1059
[Fri Oct 20 09:33:08.883493 2017] [:error] [pid 19957] [client IP:51989] >>> UNRECOVERABLE FATAL ERROR <<<\n\nimagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n\n\n/var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php:1059\n\n\n\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb \xef\xb8\xb5 \xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf \xef\xb8\xb5 \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb
[Fri Oct 20 09:33:14.254811 2017] [:error] [pid 20016] [client IP:51991] PHP Fatal error:  imagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n in /var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php on line 1059
[Fri Oct 20 09:33:14.255004 2017] [:error] [pid 20016] [client IP:51991] >>> UNRECOVERABLE FATAL ERROR <<<\n\nimagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n\n\n/var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php:1059\n\n\n\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb \xef\xb8\xb5 \xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf \xef\xb8\xb5 \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb
[Fri Oct 20 09:33:50.771160 2017] [:error] [pid 19958] [client IP:52035] PHP Fatal error:  imagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n in /var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php on line 1059
[Fri Oct 20 09:33:50.771355 2017] [:error] [pid 19958] [client IP:52035] >>> UNRECOVERABLE FATAL ERROR <<<\n\nimagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n\n\n/var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php:1059\n\n\n\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb \xef\xb8\xb5 \xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf \xef\xb8\xb5 \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb
[Fri Oct 20 09:35:34.293208 2017] [:error] [pid 20019] [client IP:52039] PHP Fatal error:  imagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n in /var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php on line 1059
[Fri Oct 20 09:35:34.293473 2017] [:error] [pid 20019] [client IP:52039] >>> UNRECOVERABLE FATAL ERROR <<<\n\nimagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n\n\n/var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php:1059\n\n\n\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb \xef\xb8\xb5 \xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf \xef\xb8\xb5 \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb
[Fri Oct 20 09:35:34.563360 2017] [:error] [pid 19962] [client IP:52040] PHP Fatal error:  imagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n in /var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php on line 1059
[Fri Oct 20 09:35:34.563557 2017] [:error] [pid 19962] [client IP:52040] >>> UNRECOVERABLE FATAL ERROR <<<\n\nimagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n\n\n/var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php:1059\n\n\n\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb \xef\xb8\xb5 \xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf \xef\xb8\xb5 \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb
[Fri Oct 20 09:35:36.434884 2017] [:error] [pid 19960] [client IP:52038] PHP Fatal error:  imagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n in /var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php on line 1059
[Fri Oct 20 09:35:36.435070 2017] [:error] [pid 19960] [client IP:52038] >>> UNRECOVERABLE FATAL ERROR <<<\n\nimagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n\n\n/var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php:1059\n\n\n\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb \xef\xb8\xb5 \xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf \xef\xb8\xb5 \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb
[Fri Oct 20 09:36:13.656572 2017] [:error] [pid 20016] [client IP:52058] PHP Fatal error:  imagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n in /var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php on line 1059
[Fri Oct 20 09:36:13.656764 2017] [:error] [pid 20016] [client IP:52058] >>> UNRECOVERABLE FATAL ERROR <<<\n\nimagecreatefromstring(): gd-png: fatal libpng error: Read Error: truncated data\n\n\n/var/www/phacility/phabricator/src/applications/files/storage/PhabricatorFile.php:1059\n\n\n\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb \xef\xb8\xb5 \xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf \xef\xb8\xb5 \xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb

Expected Behavior

Phabricator shouldn’t fail if the file was fully uploaded.

Phabricator Version

phabricator d36f98a15a6aab7cc403db0311f020174f9aa307 (Tue, Oct 17)
arcanist 617c2e46d6a5307ce23abb3d4ac3859068ebc2f9 (Tue, Oct 17)
phutil a6e490ef7ee0f8976336868eb049076be6f4a3d4 (Thu, Oct 12)
diff 3.3 at /usr/bin/diff
git 2.1.4 at /usr/bin/git

Reproduction Steps

  • Enable prototype applications to enable LFS support
  • Create a hosted git repository
  • Track, commit and push large image files to that repository

Additional info

This is a self-hosted Phabricator instance.
OS: Debian jessie
Web server: Apache 2.4.10-10+deb8u11
PHP: 5.6.30+dfsg-0+deb8u1
Excerpts from php.ini:

max_execution_time = 300
max_input_time = 120
post_max_size = 32M
upload_max_filesize = 32M

Incriminated files:

-rw-r--r-- 1 Alban 197121  5030733 Aug 10 16:41 LensDirt00.png
-rw-r--r-- 1 Alban 197121  8524297 Aug 10 16:41 LensDirt01.png
-rw-r--r-- 1 Alban 197121 12006593 Aug 10 16:41 LensDirt02.png
-rw-r--r-- 1 Alban 197121  5230447 Aug 10 16:41 LensDirt03.png

The files.enable-imagemagick configuration value is set to false, don’t know if that could help.

Thanks, see https://secure.phabricator.com/D18830.