Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash/Memory corruption in IMAP Folder #234

Open
miachm opened this issue Dec 20, 2019 · 6 comments
Open

Crash/Memory corruption in IMAP Folder #234

miachm opened this issue Dec 20, 2019 · 6 comments

Comments

@miachm
Copy link
Contributor

miachm commented Dec 20, 2019

Hi there,

I am experiencing random crashes / heap corruptions when i acces to an IMAP Folder.

The error is recreated this way:

  • Connect to an IMAP Folder.
  • Vmime does a fetch operation (opening the folder, retrieving tags, etc...).
  • A timeout exception is throwed.

The error depends of the current operation. It can produces a crash, a heap corruption or nothing at all.

A easy way to reproduce the problem is open the file IMAPFolder.cpp and insert in the line 182:
throw exceptions::operation_timed_out();

PS: I am using SSL in my tests.

@miachm
Copy link
Contributor Author

miachm commented Dec 23, 2019

Ok i see two problems:

  • The destructor of IMAPFolder tries to close the folder. But since the connection is not realiable, it throws a exception that it's ignored. The code:
    store->unregisterFolder(this);
    It's never executed in that case.
  • The destructor of IMAPConnection tries to send a LOGOUT() command. This is another source of crashes.

@vincent-richard
Copy link
Member

Hello!

Thanks for your report. However, I tried with "example6", using the latest version from master branch, and it didn't crash (IMAP server used is GMail, with SSL).

Could you please provide a minimal working example that crashes, and in which I will only have to change the IMAP host and credentials?

@miachm
Copy link
Contributor Author

miachm commented Jan 2, 2020

A timeout exception has to be thrown inside IMAPFolder code. So it's hard to recreate with a gmail account, since that server has a good reliability.

I am using a different server which it has an unstable connection. I have a timeout_exception every two hours, that's ok but it causes a crash depending where the timeout is thrown.

Since it's hard to recreate it, i suggest you to try a change in your library:

A easy way to reproduce the problem is open the file IMAPFolder.cpp and insert in the line 182:
throw exceptions::operation_timed_out();

This way, you are forcing the timeout to be happening the 100% of the time. It's a bit unnatural but it's a possible exception which could be thrown in that line. So it should not crash (it does).

@LesNewell-SheetCam
Copy link

I think I am having a similar issue. I am getting random crashes if the server throws me off. I have attached a minimum viable program that demonstrates the issue. In my case the server throws me off after about an hour, which usually results in a crash. I can provide login details to an empty account on my IMAP server if needed.

mvp.cpp.txt

@LesNewell-SheetCam
Copy link

I've been doing some more investigation highlights an oddity that explains why I am getting thrown off occasionally. Store and folder use independent connections but folder checks if it's store is connected. If you just work with one folder the store connection sits idle and times out, taking the folder with.

@RoumedG
Copy link

RoumedG commented May 11, 2021

It looks like that this issue has been solved few patches ago. I would love if you re-test this case and close the issue. Or not: more details will be quite usefull.
@miachm @vincent-richard
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants