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

Fix crash in Folder::isSyncRunning() #3586

Merged
merged 2 commits into from
Jul 28, 2021

Conversation

allexzander
Copy link
Contributor

Signed-off-by: allexzander blackslayer4@gmail.com

@@ -252,7 +252,7 @@ bool Folder::isBusy() const

bool Folder::isSyncRunning() const
{
return _engine->isSyncRunning() || _vfs->isHydrating();
return _engine->isSyncRunning() || (_vfs && _vfs->isHydrating());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to have no _vfs object or is that a state that should not be encountered?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to have no _vfs object or is that a state that should not be encountered?

@FlexW I see that in void Folder::wipeForRemoval() the _vfs is set to nullptr. Also, in some other methods, there is a check for not null _vfs.

Copy link
Contributor Author

@allexzander allexzander Jul 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FlexW Just confirmed under the debugger. void Folder::wipeForRemoval() is called before bool Folder::isSyncRunning() const, hence, _vfs is already set to nullptr. So, that check is needed.

_vfs.reset(nullptr); // warning: folder now in an invalid state
That comment, though, is weird. Not sure if it's ok to have _vfs set to nullptr here 😕

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when is Folder::wipeForRemoval() called before calling into Folder::isSyncRunning ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FlexW Just confirmed under the debugger. void Folder::wipeForRemoval() is called before bool Folder::isSyncRunning() const, hence, _vfs is already set to nullptr. So, that check is needed.

_vfs.reset(nullptr); // warning: folder now in an invalid state
That comment, though, is weird. Not sure if it's ok to have _vfs set to nullptr here confused

looks like other code expect that so I would say that even if weird seems the original author idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when is Folder::wipeForRemoval() called before calling into Folder::isSyncRunning ?

@mgallien This happens when requesting a remote wipe. That's how I was able to discover this crash. I am sure we need to add this check now. Otherwise, I have no other idea how to fix it quickly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you quickly try to extend the tests in TestFolderMan class to call into Folder::isSyncRunning() ?
that would be nice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgallien Done.

@allexzander allexzander requested a review from FlexW July 27, 2021 07:44
@mgallien
Copy link
Collaborator

/rebase

@github-actions github-actions bot force-pushed the bugfix/fix-crash-folder-isSyncRunning branch from 00eadef to e69511c Compare July 28, 2021 08:28
@allexzander
Copy link
Contributor Author

/rebase

Signed-off-by: allexzander <blackslayer4@gmail.com>
Signed-off-by: allexzander <blackslayer4@gmail.com>
@github-actions github-actions bot force-pushed the bugfix/fix-crash-folder-isSyncRunning branch from e69511c to 88d18fd Compare July 28, 2021 08:58
@nextcloud-desktop-bot
Copy link

AppImage file: Nextcloud-PR-3586-88d18fd5f31380387e30792d86607cfa7b4fd792-x86_64.AppImage

To test this change/fix you can simply download above AppImage file and test it.

Please make sure to quit your existing Nextcloud app and backup your data.

@mgallien mgallien merged commit 1e91e1b into master Jul 28, 2021
@mgallien mgallien deleted the bugfix/fix-crash-folder-isSyncRunning branch July 28, 2021 09:25
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

Successfully merging this pull request may close these issues.

4 participants