Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Pro

 AfterLogic Forum : AfterLogic WebMail Pro
Subject Topic: stream_read warning / error in logs Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
tigertech
Newbie
Newbie


Joined: 21 November 2019
Online Status: Offline
Posts: 18
Posted: 02 April 2021 at 4:13pm | IP Logged Quote tigertech

I had a user report that when he tried sending a message, he saw the error "MailSo-Net-Exceptions-SocketReadTimeoutException" in the webmail interface.

The server logs at that time show:

Code:
PHP Warning:  fread(): \\MailSo\\Base\\StreamWrappers\\SubStreams::stream_read - read 29 bytes more data than requested (8221 read, 8192 max) - excess data will be lost in [...]/mailso/lib/MailSo/Base/Utils.php on line 1807


I also similar messages occasionally in the logs at other times.

Some searching on this error suggests that this happens when PHP code uses a streamWrapper to handle fread() calls (as Afterlogic Webmail does), and streamWrapper::stream_read reads 8,192 Unicode characters that use 8,221 bytes, instead of reading 8,192 bytes.

I couldn't narrow it down to a more specific place in the code or duplicate it, but it seems like there's perhaps some kind of bug in one of the stream_read functions that's returning more bytes than requested with certain Unicode messages.

This is with Webmail Pro 8.5.3. I can't swear it's not due to a patch I've applied because I can't duplicate it on command to see if it still happens in an unpatched version, but that seems unlikely. Maybe others can see if they have similar warnings in the log.

If this isn't a known problem, I may be able to patch all the stream_read functions in our copy to check the size of the result and narrow it down further.
Back to Top View tigertech's Profile Search for other posts by tigertech
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 5622
Posted: 05 April 2021 at 12:07am | IP Logged Quote Igor

This indeed is a known issue, and quite a tricky one to catch. As far as we can tell at the moment, it's somehow related to message body content.

If you can reproduce this issue with a particular message, please save a message to Drafts before sending it out, get it as .EML file from there and provide us with it via HelpDesk for examination.

We appreciate all the help!

--
Regards,
Igor, Afterlogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
tigertech
Newbie
Newbie


Joined: 21 November 2019
Online Status: Offline
Posts: 18
Posted: 05 April 2021 at 9:50am | IP Logged Quote tigertech

I'll see if I can somehow find a message that reproduces this and let you know if I can. Thanks!
Back to Top View tigertech's Profile Search for other posts by tigertech
 
tigertech
Newbie
Newbie


Joined: 21 November 2019
Online Status: Offline
Posts: 18
Posted: 06 April 2021 at 12:22pm | IP Logged Quote tigertech

Although I don't have a message I can share (because it turns out that this bug corrupts the message even when saving as a draft), I added debugging code and found the cause.

It's happening in function stream_read() of "vendor/afterlogic/mailso/lib/MailSo/Base/StreamWrappers/SubStreams.php" when called from "Aurora\Modules\Mail\Managers\Main\Manager->saveMessage" or "->sendMessage".

This has more details and a patch that fixes the problem:

https://www.tigertech.net/patches/044-stream_read-bytes.patch

By my calculations, this bug either corrupts or prevents the sending of one in every 190 sent messages (43 / 8192) that are over 8 KB (my small hosting company has a few of these a day in the logs), so it should perhaps be made a fairly high priority.

In addition, I noticed that the "if (\is_string($mCurrentPart))" code in that same function has no provision for handling any string that is > 8192 bytes. Perhaps that situation is expected to never happen, but a better patch than mine would break the $mCurrentPart string into chunks of size $iCount, and return it piece by piece when stream_read is called repeatedly, just like it does with the "is_resource($mCurrentPart)" case. Doing that would fix both the original bug and any bug from the string being> 8192 bytes.

Thanks!
Back to Top View tigertech's Profile Search for other posts by tigertech
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 5622
Posted: 06 April 2021 at 11:58pm | IP Logged Quote Igor

Thank you so much for this, I'm forwarding the information to the developers. They'll have the patch examined, and most likely it'll be included into the nearest update of the product.

--
Regards,
Igor, Afterlogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 5622
Posted: 07 April 2021 at 12:39am | IP Logged Quote Igor

Developers have examined the patch and accepted it in the repository, so as of the next product update it will be included into the regular release. Thanks again!

--
Regards,
Igor, Afterlogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
tigertech
Newbie
Newbie


Joined: 21 November 2019
Online Status: Offline
Posts: 18
Posted: 07 April 2021 at 11:33am | IP Logged Quote tigertech

Igor wrote:
Developers have examined the patch and accepted it in the repository, so as of the next product update it will be included into the regular release. Thanks again!


Great! That patch does fix it (my logs show no more errors since I applied it to our copy of Webmail), but I also added another pull request today that handles it better, potentially avoiding other bugs in the same code. It's not as urgent, but hopefully it can be included in the future. Thanks again!
Back to Top View tigertech's Profile Search for other posts by tigertech
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 5622
Posted: 13 April 2021 at 11:50pm | IP Logged Quote Igor

I've just heard from the developers, they confirmed that the updated patch will be included as well. Thank you!

--
Regards,
Igor, Afterlogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide