XF 1.5 Invalid SOS parameters for sequential JPEG

Alpha1

Well-known member
I am getting this error:
--------------------------
ErrorException: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Invalid SOS parameters for sequential JPEG - library/XenForo/Image/Gd.php:78
Generated By: xxx, Today at 5:44 PM

Stack Trace
#0 [internal function]: XenForo_Application::handlePhpError(8, 'imagecreatefrom...', 'xxx', 78, Array)
#1 /library/XenForo/Image/Gd.php(78): imagecreatefromjpeg('/tmp/phppjiB0E')
#2 /library/XenForo/Image/Abstract.php(254): XenForo_Image_Gd::createFromFileDirect('/tmp/phppjiB0E', 2)
#3 /library/XenForo/Model/Avatar.php(125): XenForo_Image_Abstract::createFromFile('/tmp/phppjiB0E', 2)
#4 /library/Borbole/Reputation/Model/Avatar.php(9): XenForo_Model_Avatar->applyAvatar(362984, '/tmp/phppjiB0E', 2, 2592, 1944, Array)
#5 /library/XenForo/Model/Avatar.php(69): Borbole_Reputation_Model_Avatar->applyAvatar(362984, '/tmp/phppjiB0E', 2, 2592, 1944, Array)
#6 /library/XenForo/ControllerPublic/Account.php(563): XenForo_Model_Avatar->uploadAvatar(Object(XenForo_Upload), 362984, Array)
#7 /library/XenForo/FrontController.php(351): XenForo_ControllerPublic_Account->actionAvatarUpload()
#8 /library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#9 /index.php(13): XenForo_FrontController->run()
#10 {main}

Request State

array(3) {
["url"] => string(45) "https://forum.com/account/avatar-upload"
["_GET"] => array(0) {
}

["_POST"] => array(1) {
["_xfToken"] => string(8) "********"
}
}
--------------------------

is this likely an issue with my GD configuration?
 
Now that I have my redis problems solved and my error log is not constantly filling up I see that this error is frequently occurring for different users.
 
We're seeing this error message occasionally, even though we're using GD and have set the PHP config value gd.jpeg_ignore_warning, which is supposed to deal with exactly this problem. Yes, it's probably caused by broken JPEGs, but our users have no way of knowing that (since many tools do accept these images). And we'd like to eliminate spurious error messages if at all possible.

I believe XenForo_Application::handlePhpError is catching the error before gd.jpeg_ignore_warning has a chance to work. Assuming XF 1.x is still being maintained, would you consider wrapping part of XenForo_Image_Gd::createFromFileDirect with set_error_handler/restore_error_handler to fix this?
 
I am seeing this message many times a day and would love to get rid of it. I am beginning to suspect something more is at play. Because its just too frequent.

I would not be surprised if its related to mobile users who try to upload their photo's, because I have received several support tickets from mobile users having difficulties with that.

Could this be related to HEIF, HEIC or iPhone live photos?
 
Last edited:
I was able to track this down for 2 users: Both are using Android and are trying to upload a Photo taken with a Samsung.
The Photo is displayed correct on their phone, and then uploaded striaght from their phone. But when they upload it as their avatar it is flipped on the side.
When they upload they cause the above GD error.
There are a lot of accounts that have this issue of an photo rotated on its side as their avatar.

Ever since reporting this in February I have been getting dozens of these errors per day.

I hope that this gives you an idea to resolve this issue.
 
I'd guess that what you're reporting are separate issues.

An avatar rotated on its side when otherwise it appears fine when viewing on a device suggests that PHP doesn't have the EXIF extension available. XF uses EXIF data to automatically rotate images.

Worth ruling out, though, so try and get exif support sorted and see if it helps.
 
I am exclusively getting this imagecreatefromjpeg(): gd-jpeg, libjpeg error on this url:
/account/avatar-upload
it does not happen on any other url. It happens every day by many users.
Uploads to threads and gallery are fine.

It always concerns a photo taken on mobile phone.
There always is a mismatch between the TYPE and the extension. i.e. image data states TYPE = JPEG, while extension is jpg.
However, the users have only taken the photo on their phone and then uploaded to xenforo avatar function.
I can upload the same photo as an avatar or as an attachment just fine. I am using win7 But they cannot upload it from their mobile device without error.

Its a mystery to me.
 
You can replicate it by uploading a photo from a Samsung Galaxy phone to your avatar. It has to be a somewhat recent samsung galaxy. For example Samsung galaxy S5 will not cause this issue.

We are using XF 1.5.19 and php 7.1 btw.
 
Last edited:
Back
Top Bottom