News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Making An Error Show

Started by Looking, December 22, 2018, 07:50:44 PM

Previous topic - Next topic

Looking

On an external site a certain topic will not show (just blank page) when X user posts in the topic.

I have looked in all error logs: SMF, root, and server and do not see anything causing it.

I looked in the DB at the specific message and there is nothing remarkable about it but the cause of the topic not loading seems to surround the post of X. I tried deleting the message, the subject and other things but nothing helps. Only if I change the msg_id or delete the post entirely will the topic load again.

Its hard to go on anything when there isn't a reason shown.

What do you think I should do?

GigaWatt

Does the user try to attach an image when posting?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

shawnb61

All posts for that user? 

Ant http/https issues, eg., with the avatar?

I'd look closely st all user specific stuff, eg., signature, avatar, very closely...
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Arantor

For a short while at least, you can try adding $db_show_debug = true; to Settings.php which will turn off all SMF's error handling so any errors should be shown unless PHP is swallowing them... so error_reporting(E_ALL); and ini_set('display_errors', 'On'); will be your friends too.

Looking

Thanks for these tips.

Its not every post X makes. I did check avatar, signature and so forth.

I am checking into trying to attach something malicious and will use Arantor's suggestion for next rounds as I had to delete the post as the topic needed to be open.

I will keep this topic open for now. Thanks much.

Arantor

Large image attachments, or specially boobytrapped image attachments could do what you describe.

shawnb61

Was there an attachment in the post?  Or avatar?

Along the lines of what Arantor suggests, there are a large # of attachments that SMF erroneously considers security risks.  Under some circumstances (I suspect a mod disrupts the error reporting) these cause blank screens.

It may be that this user is attempting to post an image.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Arantor

I wasn't even thinking that. I was thinking about SMF's attempts to make thumbnails on large images (or small files that expand to enormous sizes)


GigaWatt

Quote from: Arantor on December 23, 2018, 06:34:53 AM
Large image attachments, or specially boobytrapped image attachments could do what you describe.

That's what I was aiming at. It's not the size of the image, it's the thumbnail generation code. SMF treats images just like any other attachment if thumbnail generation is off. If you have thumbnails turned on, it'll choke during thumbnail generation. The only possible solution is to delete the attachment from the admin panel and reattach it with reduced size (H x W).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

shawnb61

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Arantor

No but it is a good working theory without any extra details ;)

GigaWatt

I encountered this "bug" in 1.1, but it's hard to replicate it since I think it's sorta server related. It was happening with large images (W x H, not size) on one of my forum's previous hosts, but when we changed hosts, it stopped happening. I know this for a fact because nothing changed but the host and, luckily, I still had a copy of the image (I held on to it, just in case) and tried attaching it again on the new server (back then it was "the new server" :P), no errors, no white pages, the image uploaded and the thumbnail was generated, no problems whatsoever. I even left the post for a while, just to see if a white screen would pop up... nope, each time I opened the post, the thumbnail showed. I deleted the attachment and the post after a while.

Then, we moved hosts again and the problem started happening again.

Something glitches when the script tries to generate a thumbnail from a large image... maybe a resource cap/limit on some servers ???.

You know, it's really interesting to see if this only happens on a shared server, like in my case ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

SpacePhoenix

Quote from: GigaWatt on December 23, 2018, 08:06:06 PM
I encountered this "bug" in 1.1, but it's hard to replicate it since I think it's sorta server related. It was happening with large images (W x H, not size) on one of my forum's previous hosts, but when we changed hosts, it stopped happening. I know this for a fact because nothing changed but the host and, luckily, I still had a copy of the image (I held on to it, just in case) and tried attaching it again on the new server (back then it was "the new server" :P), no errors, no white pages, the image uploaded and the thumbnail was generated, no problems whatsoever. I even left the post for a while, just to see if a white screen would pop up... nope, each time I opened the post, the thumbnail showed. I deleted the attachment and the post after a while.

Then, we moved hosts again and the problem started happening again.

Something glitches when the script tries to generate a thumbnail from a large image... maybe a resource cap/limit on some servers ???.

You know, it's really interesting to see if this only happens on a shared server, like in my case ;).

Dou you have a copy of the output of PHP info for each server? Maybe there's a commonality in the config of the two servers where the problem happens.

Arantor

Very likely once the image is unpacked it consumes more memory than PHP is allowed. By default PHP is allowed to have 128MB of memory, and an image will consume at least width (in pixels) times height (in pixels) times 4 bytes of memory to open, and if resizing, you'll also need to be able to hold the resized image in memory at the same time, out of this pool of 128MB.

Likelihood is that when it works it all stays below 128MB but some combination of image sizes and preview sizes ends up causing it to go over.

Though all of this is speculation until Looking can get the error message to show.

Looking

So far it looks like they used an uploaded image. I have set up a test thread for them to try and recreate the problem but its the holiday season so things are slower. When I know for sure I will report back.

GigaWatt

Quote from: SpacePhoenix on December 24, 2018, 02:51:44 AM
Dou you have a copy of the output of PHP info for each server? Maybe there's a commonality in the config of the two servers where the problem happens.

No. Unfortunately, back then I was only a mod on the forum :-\.

Quote from: Arantor on December 24, 2018, 03:26:55 AM
Very likely once the image is unpacked it consumes more memory than PHP is allowed. By default PHP is allowed to have 128MB of memory, and an image will consume at least width (in pixels) times height (in pixels) times 4 bytes of memory to open, and if resizing, you'll also need to be able to hold the resized image in memory at the same time, out of this pool of 128MB.

Likelihood is that when it works it all stays below 128MB but some combination of image sizes and preview sizes ends up causing it to go over.

Though all of this is speculation until Looking can get the error message to show.

I was thinking along the same line. This is likely a PHP config issue, not really a bug.

Is there a way to reduce the memory load during the thumbnail generation process? Like, chop the image in chunks and process each chunk individually and then splice it back together to the thumbnail? Because, if such a thing can be achieved, then this could be a real treat for forums that share large images, but are on a shared server.

I'll see if I have the time to do some tests. I can set PHP parameters from cPanel on my host, including memory consumption... I'll see if a reeeeeally large image triggers a blank page on a 64MB memory limit ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."


Looking

Its confirmed - its an image upload; the original image is not large in size- only 600kb but its dimensions are around 7000x7000. I tried uploading here: https://www.simplemachines.org/community/index.php?topic=564202 and got a blank page, second try got a 400 Bad Request page and third try blank page but at least the topic still loaded.

I reduced the image's dimensions by 50% and it took it up. Does SMF have a max check for this by default so it does not blank the topic out because one person made an upload that was too big?

Arantor

No, it's exactly as we said. 7000x7000 image will take around 186MB to open (7000x7000x4 bytes per pixel fully uncompressed) which is over the 128MB normal limit, so it fails.

It subsequently fails when viewing the topic because SMF sees it should have a thumbnail, but doesn't, and tries to make it on the fly, and again runs into the memory limit and dies.

shawnb61

I think the mod Illori provided the link to will fix it!

I had the same issue a while back...
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Arantor

It probably would, provided the image was never large enough to consume more than 2GB of RAM.

Looking

Thank you kindly all. I am glad for the tips in solving this issue and learning the cause for next time.

GigaWatt

Quote from: Looking on December 24, 2018, 01:57:29 PM
Its confirmed - its an image upload; the original image is not large in size- only 600kb but its dimensions are around 7000x7000.

Yep, told ya ;). It's not the size, it's the dimensions ;). Tried recompressing some of the images I had problems with 10 different ways, if you don't scale it, it won't upload... well, it will, if you don't have thumbnails enabled :P :D.

BTW, is there a way to NOT save the thumbnails of the images in the Attachments dir and let SMF generate the thumbnails each time the thread is viewed?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Advertisement: